Its very simple to load the table value to dropdown box in ruby on rails.
Syntax :
select(:model, :attribute, rails query)
Example :
Now you need to load the countries table table to drop down mean
select(:Country, :cname, Country.all.collect {|c| [ c.name, c.id ] })
Country => Its model name
cname => Field name
Country.all => Its load the all values to dropdown.
Its like "SELECT *FROM COUNTRIES"
Comments
Post a Comment