I am using Rails 4 with Devise, Cancan and Rollify.
I have a modal change user index. However, when I try to update the role, I get the following error: "Wrong number of arguments (2 for 1)"
The error is on line 16 of my user controller 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
A form that submits parameters:
<div id="role-options-<%= user.id %>" class="reveal-modal medium" style="display: none;"> <%= simple_form_for user, url: user_path(user), html: {method: :put, class: 'custom' } do |f| %> <h3>Change Role</h3> <%= 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 %> <%= f.submit "Change Role", class: "small button" %> <a class="close-reveal-modal" href="#">Close</a> <% end %> </div>
Here is my role model:
class Role < ActiveRecord::Base has_and_belongs_to_many :users, :join_table => :users_roles belongs_to :resource, :polymorphic => true scopify end
I assume this has something to do with the change from attr_accessible to Strong Paramenters in Rails 4, but I'm not sure. If so, where can I put the private method?