Ruby on Rails Wednesday, March 23, 2016

On 23 March 2016 at 09:47, Johnny Stewart <lists@ruby-forum.com> wrote:
> Yes - I see that, it was late, got albums and images the wrong way round
> there..
>
> I've been learning for a few months now, so I've seen and completed that
> tutorial and a few others. Its an excellent resource especially
> considering its free!
>
> I'm going to do a bit of reading up on associations today, but think i
> may yet just go with a hash or array of album names for simplicity,
> unless something major jumps out at me.

Don't do that, you will regret it. Associations and the rails magic
they give you are one of the fundamentals of rails. For example,
having setup the associations you will be able to get the albums for a
user using

current_user.albums

and to get the images for a user for a particular album something like
current_user.albums.where( category: "the category").images

The code you will need to write to do the same using a hash will be
much more complex

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

No comments:

Post a Comment