Reputation: 360
I'm currently working on a Rails project right now, doing learning and working on it at the same time...
So I was just trying to create a form for editing user and this is how I doing it
<%= form_for(@user,:url => { :action => "update",:controller => "users" }) do |f| %>
<% @f = f %>
<%= render 'users/dialog'%>
<% end %>
But then I got the error
No route matches {:action=>"update", :controller=>"users"}
Which I did not expect it to be happen since
<%= form_for(@user,:url => { :action => "create",:controller => "users" }) do |f| %>
is working for me.
Didn't find some answer I want on Google, hope someone can help me out on this
Thanks
Upvotes: 0
Views: 2747
Reputation: 176402
No need to supply a :url
if you already pass the @user object.
<%= form_for(@user) do |f| %>
<%= render 'users/dialog'%>
<% end %>
Also, avoid setting variables such as @f
in the view. This is not view's responsibility.
Upvotes: 2