Reputation: 376
I have below piece of code:
params.require(:posting_status).permit(:email, :craig_password, :mail_password, :posting_id, post_to:[])
this line doesn't give syntax error, but when i do like:
params.require(:posting_status).permit(:email, :craig_password, :mail_password, post_to:[], :posting_id)
this gives syntax error, Can't find the reason.
Upvotes: 0
Views: 50
Reputation: 261
In the first case you used symbol at the beginning and (implicit!) hash at the end.
In the second case implicit hash not at the end. Explicit hash solves the problem.
params.require(:posting_status).permit(:email, :craig_password, :mail_password, {post_to:[]}, :posting_id)
P.S. Source code of 'permit' method:
File actionpack/lib/action_controller/metal/strong_parameters.rb, line 325
def permit(*filters)
params = self.class.new
filters.flatten.each do |filter|
case filter
when Symbol, String
permitted_scalar_filter(params, filter)
when Hash then
hash_filter(params, filter)
end
end
unpermitted_parameters!(params) if self.class.action_on_unpermitted_parameters
params.permit!
end
Upvotes: 1