Mohammad Seif Mohammad Seif - 5 months ago 44
Ruby Question

How to get params from select form in rails

I have this code in my view:

<% select("post", "person_id", Person.all.collect {|p| [, ] }, {include_blank: true }) %>

I want to get value of
from params.

When I am trying

@person_Select = params[:post[person_id]]

I am getting error.


You should use below way to get your params in controller:

@selected_person = params[:post][:person_id]