Form_for - over riding the controller that generates the for


#1

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| %>

Username:
<%= f.text_field :username, :size => 30 %>

Password:
<%= f.password_field :password, :size => 30 %>

<%= submit_tag 'Login' %> <% end %>

This is the form that is created:

LOGIN PASSWORD

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!


#2

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| %>

Username:
<%= f.text_field :username, :size => 30 %></
p>

Password:
<%= f.password_field :password, :size => 30
%>


<%= submit_tag ‘Login’ %>
<% end %>