So I posted last week asking about new learning resources. I watched
the lynda.com RoR videos, and now I just started reading the Ruby for
Rails book. Both of these sources code in different ways, and I was
wondering which way is most common. In other words, is one of these
ways frowned upon in the Rails community? Keep in mind that these are
rather specific examples and not necessarily complete lines of code.
-
First is how things are read from a database, or more specifically,
sorting. One does this
@albums = Album.find(:all, :order => “title ASC”)
while the other does this
@composers = Composer.find(:all).sort_by{|c| [c.last_name,
c.first_name]} -
Looping.
<% for composer in @composers -%>
and
@composers.each do |composer| -
dynamic links
link_to(composer.first_name + " " + composer.last_name
and
link_to(“#{composer.first_name} #{composer.last_name}”
In all cases I prefer the first (lynda.com) method, either because
it’s shorter or because it requires less symbols. The Ruby for Rails
method seems to be a lot more object focused. So which of these do
you see more often or is the common way? Or does it not matter?