Rails Undefined Method 'Errors' for Nil:Nilclass in Simple_Form

Why does removing line of code produce undefined method `errors' for nil:NilClass in simple_form

Your session object wasn't instantiated anywhere, you are passing a string.

<%= simple_form_for(:session, ...) %>

For f.object.errors to work something like an ActiveRecord / ActiveModel instance should have been passed.

Rails simple form undefined method `model_name' for nil:NilClass

Just create new instance of Review Modal in show action of RecipesController -:

@review = Review.new

that's all, i will work. :)

Rails - Simple Forms - undefined method `model_name' for nil:NilClass

As you said correctly in your question, simple_form should be used to render forms to the user when her actions are related to the creation or edition of ActiveRecord models.

For instance, when writing down code to enable a search feature, where your goal is to simply pass a bunch of user chosen params to a controller, you should not use it. I believe you are in a similar position with the feature you described.

Simple solution though: use rails form related DSL to get your form going!

Hope it's the answer you needed. Feel free to ask for more details if needed. Cheers!

Ruby on rails - undefined method `each' for nil:NilClass

Assigns subscriptions in a create action too:

before_filter :set_subscriptions, only: %w(new create) #for edit and update if needed

private
def set_subscriptions
@subscriptions = Businesses::Subscription.all
end

Or add @subscriptions = Businesses::Subscription.all directly to create action after the saving is failed and you re-render new form.

simple-form association gives undefined method `klass' for nil:NilClass error

There is a missing relationship between Rollout and RolloutItem:

class Rollout < ActiveRecord::Base
has_many :rollout_items # This.
has_many :items, :through => :rollout_items
end

The same goes for Item.

undefined method `model_name' with simple_form on Rails 5

def edit
@post = Post.find(params[:id]) # <=========
end

undefined method `[]' for nil:NilClass but the article is published

unless params[:progress_attachments].nil?
params[:progress_attachments]['image'].each do |a|
@progress_attachment = @progress.progress_attachments.create!(:image => a)
end
end


Related Topics



Leave a reply



Submit