On 10 March 2010 14:41, Andy Jeffries <[email protected]> wrote:
> I would change that as follows:
> CLUB_TYPES = {
>   "pub" => "Public",
>   "vil" => "Village",
>   "pvt" => "Private"
> }
>

...as long as there's no need for clubtypes to be displayed in any
particular order (arrays are returned in order, hashs aren't
necessarily)


For the minuscule amount of extra effort involved, create a model for
club types, seed it, and give it a "position" column if you want to
manage the order (or just put an :order clause on your default
finder).

Then use ClubType.all or named scopes for more functionality ...

Your clubs can change their club_type text column into a club_type_id
integer and add a belongs_to relationship, allowing you to do nice
easy queries, leverage Rails' functionality, and get rid of those
"magic" array/hash variables.

Sometimes things that seem like shortcuts (like using an array for
some "static" data) can quickly turn into dead ends. The framework
does all the hard work for you, so you might as well use it.

-- 
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