feat(roles): add strong params

This commit is contained in:
Luis Castro 2019-08-06 16:07:55 +02:00 committed by Eric Schultz
parent 27f9d3bda9
commit 9d2d6425ab
2 changed files with 10 additions and 6 deletions

View file

@ -7,7 +7,7 @@ class RolesController < ApplicationController
before_action :authenticate_nonprofit_admin!
def create
role = Role.create_for_nonprofit(params[:role][:name].to_sym, params[:role][:email], FetchNonprofit.with_params(params))
role = Role.create_for_nonprofit(role_params[:name].to_sym, role_params[:email], FetchNonprofit.with_params(params))
json_saved role, 'User successfully added!'
end
@ -22,4 +22,10 @@ class RolesController < ApplicationController
render json: {}
end
end
private
def role_params
params.require(:role).permit(:name, :email)
end
end

View file

@ -11,11 +11,9 @@ class Role < ApplicationRecord
:event_editor # //
].freeze
# TODO:
# attr_accessible \
# :name,
# :user_id, :user,
# :host, :host_id, :host_type # nil, "Nonprofit", "Campaign", "Event"
# :name,
# :user_id, :user,
# :host, :host_id, :host_type # nil, "Nonprofit", "Campaign", "Event"
belongs_to :user
belongs_to :host, polymorphic: true