NewB questions

Hi,

A project came up that has made me realize that it’s time to learn RoR.
I’ve got everything up and running (Ruby 1.8.6, Rails 2.1, MySQL 5,
Webrick) and am using Aptana with RadRails for development. I’ve
installed the “recipes” demo application and have been poking around for
the past couple of hours, and now I have a few questions about how
things work:

  1. Where’s the SQL? I see the methods that get the data in
    recipes_controller.rb, but can’t for the life of me figure out how Rails
    gets the info from the database, SQL-wise.
  2. On the main recipes page, there is a link to create a “new recipe”
    with this code: <%= link_to ‘New recipe’, new_recipe_path %>. I’m
    assuming new_recipe_path is a variable set somewhere, but I can’t find
    where it’s being set?
  3. How do I extend Rails? I like the idea of things like <%= link_to
    … %>, but say I want to do something like this: <%= link_image_to
    image_path(“new.png”), new_recipe_path %> (i.e. make the link an image
    rather than text, which I can’t find in the API so assume does not
    exist).
  4. Where do I set constants for the entire app,
    /app/controllers/application.rb?

One thing that has also occurred to me while looking at the sample app
and a number of online resources is that Ruby on Rails is somewhat
limited in its scope; in other words, it seems great for fairly
straightforward applications, but for “big and ugly” apps like auctions,
online ticket sales, and that sort of thing, it might not be the best
tool to use. Is this a fair assessment? My other primary programming
languages are Java and ColdFusion; CF gets bashed a lot for being web
development on training wheels, but sometimes that’s what I like about
it…however, I’ve been able to build some rather complex apps with it.

Thanks for any answers and/or insight you can provide,

Pete

  1. All SQL commands are handled by Rails unless you explicitly tell it
    to do
    something in SQL.
  2. new_recipe_path is a method generated by calling map.resources
    :recipes
    in your config/routes.rb file. For more information see here:
    frozenplague.net
  3. Just nest the method calls: link_to(image_tag(“woop.jpg”),
    new_recipe_path)
  4. You can set constants in config/environment.rb, right at the bottom
    of
    the file (that’s my favourite spot)


Appreciated my help?
Recommend me on Working With Rails
http://workingwithrails.com/person/11030-ryan-bigg

Pete Ruckelshaus wrote:

Hi,

A project came up that has made me realize that it’s time to learn RoR.
I’ve got everything up and running (Ruby 1.8.6, Rails 2.1, MySQL 5,
Webrick) and am using Aptana with RadRails for development. I’ve
installed the “recipes” demo application and have been poking around for
the past couple of hours, and now I have a few questions about how
things work:

Hi Pete,

Have you picked up a book for learning Rails? That would be very good
investment, not only of a few of your dollars, but a number of your
hours. Agile Web D. with Rails is a great resource. It is
currently being updated for Rails 2.x.x, so if you get the older one, it
will be for Rails 1.2. There are some differences that could trip you
up, but there have been some posts here and elsewhere describing the
differences and making it possible to use the older book with newer
Rails. Or, you could just install Rails 1.2.6 and not worry about it.

Peace,
Phillip