开发者

No Method Error on edit method

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开发者_如何学Go. What am I doing wrong?


The error is not in your view, the form_for tag calls some methods on the resource passed in, in this case @event. Make sure that @event is 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.


Check that you are setting @event in your controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜