Ruby on Rails Sunday, May 8, 2016

Hi,

On Sun, May 8, 2016, at 20:01, Johnny Stewart wrote:
> I have a model where I want a few specific choices for a dropdown to set
> a variable, very much like this:
>
> http://stackoverflow.com/questions/14113057/how-to...
>
> I'm trying to work out why all the answers to this question involve
> creating a new model and db table just for the three choices outlined.
> Would it not make more sense just to define the choices in the User
> model and have a column in the User db table with the chosen one saved
> there (assuming there are only three choices, which are very unlikely to
> change and the user will only have one at any one time).
>
> I assume I am missing something important here...
>


At least two answers suggested using constant/variable in model. There's
also alternative of using enum [1].

[1] http://api.rubyonrails.org/classes/ActiveRecord/Enum.html

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1462706203.3362052.601389217.67A63365%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment