If you need let's say the countries for a select statement I would
just create this in a migrations/country model that loads the data
into an array on startup. This will then be cached in production and
only loaded once. I use something like this for one project:

class State < ActiveRecord::Base
  NAMES_ABBREVIATIONS = self.find(:all, :order => :name).map do |s|
    [s.name, s.abbreviation]
  end
end

<%= address_form.select(:state, State::NAMES_ABBREVIATIONS, :prompt =>
'select', :label => "State", :required => true) %>

This gives only one hit to the database on startup.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to