Skip to main content

Posts

Showing posts from September, 2014

Load value to dropdown from table in Ruby on Rails

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"