ruby on rails - Modify Nested_Field before adding association Cocoon -
after user submits form, before association added, possible modify nested field during time?
for example nested fields may like:
<div class='nested-fields'> <div class="field"> <%= f.label :count %> <%= f.number_field :count %> </div> <%= link_to_remove_association "remove section", f %> </div>
say want multiply count x 2 before adding association (after user submits form). possible?
or more complex example, might want convert integer string save association.
link issue: https://github.com/nathanvda/cocoon/issues/361 (i told post on so)
yes, can modify permit params:
def some_params params.require(:some).permit(:count).tap |white_list| white_list[:count] = 2 * params[:some][:count].to_i end end
Comments
Post a Comment