Rolling with Ruby on Rails
Subject:   don`t understand action="../update/.."
Date:   2006-10-04 06:01:56
From:   curth
Response to: don`t understand action="../update/.."

You are using an incorrect mental model of how things work.

The "recipe" part of the URL is the is the controller name. This maps to the class named RecipeController which is found in the file app/controllers/recipe_controller.rb. Each controller can have an associated folder that contains view templates for that controller. Hence, you will find an app/views/recipe folder.

The "list" part of the URL is he action, and that maps to a method in the controller class. If you open the file containing the controller class, you should see a "list" method defined.

You should *not* have a list folder. Every action can have an associate view template, so what you *should* have is an app/views/recipe/list.rhtml file.

Now, for the reference to "update". First of all, I should point out that this is not the recommended way to do forms in rails (I was a neophyte myself, when I wrote that). Instead, I should have used the form_tag helper to generate the form tag for me.

However, this does work, here's what's going on...

This form is being displayed from a web page with a URL that is somethig like:


So the URL on the action attribute of the form tag ends up being something like this:


This is a relative URL, so it results in the browser resolving the URL to:


This means that it goes to "recipe" controller, and then the "update" method within that controller. You will *not* find a view template for update because it doesn't display anything. It updates he database and then redirects to another URL.

Unfortunately, if you go look in the recipe controller you will not see an update method, because it is being generated dynamically by the "scaffold :recipe" line. All the other methods are also being generated by the scaffolding, but we have chosen to override them by providing our own definitions.

Hope that helped... good luck!

1 to 1 of 1
  1. don`t understand action="../update/.."
    2006-10-04 08:50:20  rudyOnTheTrain [View]

1 to 1 of 1