0

I have this: view:

confirmations.each do |c|
  <%= render "form", confirmation: c %>
end

partial:

<%= simple_form_for @confirmation do |f| %>
    ...

Rails for some reason gives me this error:

NoMethodError in Rosters#show

undefined method `model_name' for nil:NilClass

highlighting the line in the above partial.

1 Answer 1

1

NoMethodError in Rosters#show

undefined method `model_name' for nil:NilClass

It should be <%= simple_form_for confirmation do |f| %> not <%= simple_form_for @confirmation do |f| %> as your variable is confirmation not @confirmation

Sign up to request clarification or add additional context in comments.

4 Comments

In other files I have <%= render "form", confirmation: @c %> and it works
@DrevanTonder It all depends on existence or access of @confirmation. Does the error resolved?
@DrevanTonder Then you should accept my answer and BTW read more about local variables and instance variables in Ruby.
Stackoverflow was making me wait for a minute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.