Here i am using *rails3*, here the view.html.erb form have one login
button, so when i click on that button, gives no routes matches :controller
=> 'home', :action => 'login'. But i have put that in routes.rb. Why this
happening?

*view.html.erb*

<%= form_tag( { :controller => 'home', :action => 'login' }, { :method => 'post'}) do %>
<%= text_field(:name, :name, :class => "span2",:placeholder => "Username") %>
<%= password_field_tag(:password, :password, :class =>"span2") %>
<%= submit_tag "Login", :class => "btn btn-primary" %>
<% end %>
routes.rb


resources :home do
post :login, :on => :member
end

homecontroller.rb

class HomeController < ApplicationController
def login

end
end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/dwIdjTTKPmwJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Xuan at Feb 29, 2012 at 2:41 pm
    You should define it as

    :on => :collection

    Problem is you defined it as :member, so it expects an id to be
    passed, so the expected url would look like /home/:id/login

    Hope this helps!
    On 29 feb, 15:14, amvis wrote:
    Here i am using *rails3*, here the view.html.erb form have one login
    button, so when i click on that button, gives no routes matches :controller
    => 'home', :action => 'login'. But i have put that in routes.rb. Why this
    happening?

    *view.html.erb*

    <%= form_tag( { :controller => 'home', :action => 'login' }, { :method => 'post'}) do %>
    <%= text_field(:name, :name, :class => "span2",:placeholder => "Username") %>
    <%= password_field_tag(:password, :password,  :class =>"span2") %>
    <%= submit_tag "Login", :class => "btn btn-primary" %>
    <% end %>
    routes.rb

    resources :home do
    post :login, :on => :member
    end

    homecontroller.rb

    class HomeController < ApplicationController
    def login

    end
    end
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 29, '12 at 2:15p
activeFeb 29, '12 at 2:41p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Xuan: 1 post Amvis: 1 post

People

Translate

site design / logo © 2022 Grokbase