Custom helpers for list of options?

Hi all,

I have a model that “belongs_to” many other models, many of those
models are just list of names, like country, state, city, profession
… I read about the country_select helper.

Is better to have all those tables or use custom helpers? what the rails
way?

Thanks.

For example : Parked at Loopia

= Schema

country_id integer

city_id integer

state_id integer

profession_id integer

category_id integer

class User < ActiveRecord::Base
belongs_to :country, :city, :state
belongs_to :profession, :category, :subcategory
end

=========== VS

= Schema

country :string

city :string

state :string

profession :string

category :string

class User < ActiveRecord::Base
end

class ApplicationHelper
def city_select (…)
end

end

Pedro Del G.

Email : [email protected]

I use tables and then just have helpers that build the arrays for
the select_options for the view.

For example, I have a table for languages and I have this in my
helper:

def language_options
Language.find(:all, :order => “language”).collect {|l| [ l.language,
l.id ]}
end

Then from my view:

<%= select ‘document’, ‘language_id’, language_options %>

Hope this helps.