On 4 May 2015 at 10:31, Hemant Bhargava <li...@ruby-forum.com> wrote:
> Hi,
>
> Not being an expert in RoR, I have a logical query. It is not a
> programming question.
>
>
> Situation is :
>
> I have a Book model and status of the book can be anything from NEW,
> OLD, VERY_OLD. It can be NEW, OLD both or it could be OLD and VERY_OLD
> both. What would you suggest to implement in such a case? I wanted to
> save user choice in database.
>
> I can create new model for Book condition but I feel that there must be
> some other nice way to handle it. Is there?

Is there any other information associated with the status?  If not
there is no point having another model.  Just have boolean fields for
each status and set them as appropriate.  Or if there is a specific
set of valid combinations (old, very old, old+very old etc) then you
could use an enum field with a value for each combination.

Colin

-- 
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+unsubscr...@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/CAL%3D0gLtOKX5z_OpxGs6qJbVkzPZj_T6hj312jWQfb4933aHCew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to