Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass extra parameter in rails form_for

How I can get redirect_id from this form?

<%= form_for(@category) do |f| %>
 <%= hidden_field_tag :redirect_id, :value=>5 %>
 <%= f.text_field :text %>
<% end %>

In controller I can get only category params in my params array.

Maybe because I'm using only this code to filter parameters in controller.

def panel_category_params
  params.require(:category).permit(:text)
end
like image 571
Gediminas Avatar asked Mar 14 '23 13:03

Gediminas


1 Answers

Following should work:

<%= hidden_field_tag 'redirect_id', 5 %>

See examples of using hidden_field_tag.

like image 72
Andrey Deineko Avatar answered Mar 20 '23 12:03

Andrey Deineko