Note that there are some explanatory texts on larger screens.

plurals
  1. POwrong number of arguments (2 for 1) Rails 4. Maybe strong_params issue
    text
    copied!<p>I'm using Rails 4 with Devise, Cancan and Rollify.</p> <p>I've got an index of users with a modal to change the role. However when I try to update the role I get the following error: "wrong number of arguments (2 for 1)"</p> <p>The error occurs in line 16 of my User controller code:</p> <pre><code>13 def update 14 authorize! :update, @user, message: 'Not authorized as an administrator.' 15 @user = User.find(params[:id]) 16 if @user.update_attributes(params[:user], as: :admin) 17 redirect_to users_path, notice: "User updated." 18 else 19 redirect_to users_path, alert: "Unable to update user." 20 end 21 end </code></pre> <p>The form that is sending the params is:</p> <pre><code>&lt;div id="role-options-&lt;%= user.id %&gt;" class="reveal-modal medium" style="display: none;"&gt; &lt;%= simple_form_for user, url: user_path(user), html: {method: :put, class: 'custom' } do |f| %&gt; &lt;h3&gt;Change Role&lt;/h3&gt; &lt;%= f.input :role_ids, collection: Role.all, as: :radio_buttons, label_method: lambda {|t| t.name.titleize}, label: false, item_wrapper_class: 'inline', checked: user.role_ids.first %&gt; &lt;%= f.submit "Change Role", class: "small button" %&gt; &lt;a class="close-reveal-modal" href="#"&gt;Close&lt;/a&gt; &lt;% end %&gt; &lt;/div&gt; </code></pre> <p>Here's my Role Model:</p> <pre><code>class Role &lt; ActiveRecord::Base has_and_belongs_to_many :users, :join_table =&gt; :users_roles belongs_to :resource, :polymorphic =&gt; true scopify end </code></pre> <p>I'm guessing that it has something to do with the change from attr_accessible to Strong Paramenters in Rails 4 but I'm not sure. If it is, where do I put the private method?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload