Monday 15 June 2015

ruby on rails - Cocoon - Wrong number of arguments (1 for 0) for look-up or create :belongs_to -



ruby on rails - Cocoon - Wrong number of arguments (1 for 0) for look-up or create :belongs_to -

following cocoon wiki implementing the look-up or create :belongs_to i'm receiving error: wrong number of arguments (1 0). i'm not sure referring beingness i'm next tutorial verbatim aside using slim precompiler. here's code looks like:

models

class project < activerecord::base belongs_to :user has_many :tasks accepts_nested_attributes_for :tasks, :reject_if => :all_blank, :allow_destroy => true accepts_nested_attributes_for :user, :reject_if => :all_blank end class user < activerecord::base has_many :projects end

projects form

<%= simple_form_for @project |f| %> <%= f.input :name %> <%= f.input :description %> <h3>tasks</h3> <div id="tasks"> <%= f.simple_fields_for :tasks |task| %> <%= render 'task_fields', :f => task %> <% end %> <div class="links"> <%= link_to_add_association 'add task', f, :tasks %> </div> </div> <div id="user"> <div id="user_from_list"> <%= f.association :user, collection: user.all(:order => 'name'), :prompt => 'choose existing user' %> </div> <%= link_to_add_association 'add new person owner', f, :user %> </div> <%= f.submit %> <% end %>

projects controller

... def project_params params.require(:project).permit(:name, :description, tasks_attributes: [:id, :description, :done, :_destroy], user_attributes: [:id, :name]) end

backtrace

app/views/projects/_form.html.erb:16:in `block in _app_views_projects__form_html_erb___3132123068035883478_70337216288160' app/views/projects/_form.html.erb:1:in `_app_views_projects__form_html_erb___3132123068035883478_70337216288160' app/views/projects/new.html.erb:3:in `_app_views_projects_new_html_erb__2418839848133678570_70337176808940'

activerecord#all has been changed in rails 4 - doing scoped used do. not expect params. instead of user.all(order: 'name') do:

user.order(:name)

ruby-on-rails ruby forms cocoon-gem

No comments:

Post a Comment