Mindtonic
2007-Jul-31 12:20 UTC
form_for - over riding the controller that generates the form
Hello, I am trying to install my login and search forms as default parts of the layout. This is the code I am using: <% form_for :user, :url => {:action => ''authenticate''} do |f| %> <p>Username:<br /><%= f.text_field :username, :size => 30 %></p> <p>Password:<br /><%= f.password_field :password, :size => 30 %></p> <%= submit_tag ''Login'' %> <% end %> This is the form that is created: <form action="/pages/authenticate" method="post"> <p> LOGIN <input id="user_username" name="user[username]" size="10" type="text" /> PASSWORD <input id="user_password" name="user[password]" size="10" type="password" /> <input name="commit" type="submit" value="Login" /> </p> </form> The form action is referring to the pages controller. I need it to refer to the accounts controller, which the same code does after whenever permissions are not granted. How can I tell form_for which specific controller to reference? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mindtonic
2007-Jul-31 12:31 UTC
Re: form_for - over riding the controller that generates the form
The answer turns out to be quite simple: form_for :user, :url => {:action => ''authenticate'', :controller => ''account'' } <% form_for :user, :url => {:action => ''authenticate'', :controller => ''account'' } do |f| %> <p>Username:<br /><%= f.text_field :username, :size => 30 %></ p> <p>Password:<br /><%= f.password_field :password, :size => 30 %></p> <%= submit_tag ''Login'' %> <% 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- How to use a form.check_box ?
- Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
- Setting default value in text_field/password_field
- ActionController::InvalidAuthenticityToken in LoginController
- Routing Error using Paperclip