Hello!
I have watched Railscast about strong_parameters,
http://railscasts.com/episodes/371-strong-parameters (sorry, for subscribers only), and implemented that solution.
Author suggested to filter out forbidden attributes. And it is really needed, because strong_parameters will not raise exception on attempt to change forbidden attribute. Success message will be displayed to user, but attribute will stay unchanged. It is expected behaviour (
https://github.com/rails/strong_parameters/issues/54#issuecomment-9771662)
So, that Railscast's code to filter out forbidden attribute is:
<% if permitted_params.topic_attributes.include? :sticky %>
<div class="field">
<%= f.check_box :sticky %>
<%= f.label :sticky %>
</div>
<% end %>
Using simple_form it can be written like this:
<%= f.input :sticky, :as => :boolean if permitted_params.topic_attributes.include?(:sticky) %>
It's already too much I think. But it is only one attrbute. For five attributes it will be five permitted_params.topic_attributes.include?()
It probably can be shortened, but still there is a need to specify some condition for each attribute to filter out forbidden ones.
So maybe simple_form gem is the right place to auto-apply strong_parameters permissions? Or there is another way to do it?