Jump to content

The ultimate community for Ruby on Rails developers.


Photo

To fill in (select html) on the basis of the select html) above

halper Coffe Script Ajax

  • Please log in to reply
2 replies to this topic

#1 Pinta777

Pinta777

    Dispatcher

  • Members
  • 38 posts

Posted 09 October 2014 - 06:40 AM

There are 2 models

belongs_to :region and has_many :cities

 

In different regions, other city

In one form, fill and cities and regions

But the city should be derived on the basis of regions.

 

I wanted to do it through halper

 f.grouped_collection_select

But the customer wants to separate fields for it

<select> 

html)

 

Please halp))

 

 



#2 Pinta777

Pinta777

    Dispatcher

  • Members
  • 38 posts

Posted 09 October 2014 - 06:23 PM

give a little hint?



#3 Ohm

Ohm

    Driver

  • Moderators
  • 530 posts
  • LocationCopenhagen

Posted 10 October 2014 - 09:49 AM   Best Answer

So, why not just use the grouped_collection_select helper?

# controller
...

def show
  @regions = Region.all
end

...

# view
...

f.grouped_collection_select(:city, :city_id, @regions, :cities, :name, :id, :name)

...

or something similar: http://apidock.com/r...llection_select


  • Pinta777 likes this

Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk






Also tagged with one or more of these keywords: halper, Coffe Script, Ajax

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users