Ruby on Rails Monday, November 3, 2014



On Sunday, 2 November 2014 20:57:43 UTC-5, Ruby-Forum.com User wrote:
Hi,
When I try to update a field using the update button I am getting the
error: No route matches [PATCH] "/profile".  Its obviously missing the
/:id but I can't figure out why...

I am using a form_for in an edit view.

<%= form_for @profile, :html => { :class => 'form-horizontal '} do |f|
%>
      ...
        <%= f.submit 'Update', :class => 'btn btn-primary' %>
      ...
 <% end %>

@profile contains #<Profile:0x00000104c26398> as it should.

routes contains: resources :profiles  and the resulting routes appear OK


From the route it's generating, I suspect you have a `resource :profile` someplace above this. That matches the controller actions you're showing, which use `current_user.id` instead of `params[:id]`. You'll likely need to specify the URL explicitly to `form_for`.

--Matt Jones

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/36c37534-b55b-431b-a1a5-e1e18b842024%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment