Reputation: 1062
I want to retrieve hidden field in a form for. Here is my form :
<%= bootstrap_form_for :cvs do |f| %>
<%= f.text_field :nom, label: "Nom du nouveau CV", :required => true %>
<%= f.hidden_field :cvuse, :value => params[:user] %>
<%= f.submit class: "btn btn-primary"%>
<% end %>
When I check my server logs I could see my variable passed :
Started POST "/cvs" for 127.0.0.1 at 2015-08-31 14:30:36 +0200
Processing by CvsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"someCrazyKey", "cvs"=>{"nom"=>"dd", "cvuse"=>"1"}, "commit"=>"Save Cvs"}
Unpermitted parameter: cvuse
Do you know how I could retrieve this variable cvuse
. just for precision this form execute the create
method in my controller.
Upvotes: 0
Views: 96
Reputation: 15109
Rails 3 without strong params:
params[:csv][:csvuse]
Rails 4 with strong params:
def csv_params
params.require(:csv).permit(:csvuse)
end
def create
csvuse = csv_params[:csvuse]
end
Upvotes: 3