Forum: Ruby on Rails Rails3.2 remote select

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
48c1402b87ff63718ba21a446fe455ef?d=identicon&s=25 Alessio V. (alessio_v)
on 2017-02-02 09:32
Hi, I work with remote select. I have two select and in base of the
value of the first select I fill the second select..for example

 <%= form_for(@person) do |f| %>

     <%= f.collection_select(:car_id,cars,:id,:tcode, {}, {data:{
remote: true, url: ajax_filter_magazine_car_path(0),"data-type" =>
"json"}}) %>

     <%= f.collection_select(:magazine_id,cars,:id,:tcode, {}) %>

  </form>

my problem is that rails send to the controller the json in this format

params[:person][:car_id]  so name of model and key-value

But I have to execute in many case this operation in differents
form..This format is a problem because the json can be

params[:person][:car_id]
params[:office][:car_id]
params[:calendar][:car_id]


But i want only params[:car_id]
So in the controller I have to parse in many different way the json..The
is the possibility to send only params[:car_id]?
790aa5104ca3a098de140f7adec3c043?d=identicon&s=25 Anusha Mummina (anushamummina)
on 2017-03-09 12:08
change the name of select field tag and try once.
This topic is locked and can not be replied to.