I am trying to edit my events model. Here is what I have for the edit:
Edit Event
<%= form_for(@event) do |f| %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.label :description %><br />
<%= f.text_field :description %>
<%= f.submit "Update" %>
</div>
<% end %>
I made the route as so:
resources :events do
member do
post :attend
post "/remove_attendee/:user_id" => "events#remove_attendee", :as=>:remove_attendee
post "/edit" => "events#edit"
end
But I am getting a no method error. NoMethodError in Events#edit and it is on line 3 which is the form_for place. What am I doing wrong?
The error is not in your view, the
form_fortag calls some methods on the resource passed in, in this case@event. Make sure that@eventis not nil and that the lookup to pull up the resource is working as intended. Again, seeing you controller/model/etc. code along with the full error would help.