Saturday, August 16, 2008

Controlling what your homepage shows

Your home page is (say): http://www.something.com/, and you want this home page to show some meaningful dynamic output, rather than a static output.
Dynamic output comes from calling a controller (say, "product") and action (say "listall"). To do this, first rename your index.html file (public/index.html). If you don't, rails will display the index.html file by default.
Next, open your routes.rb file (config/routes.rb) and add the following line:

map.connect ' ', :controller => "product", :action => "listall"

This will ensure that the home page will show the output of action "listall" in controller "product".

Friday, August 15, 2008

validations

Validations can be created for each model in your app. For example if you have a model called "page", and say this model maps to a database table called "page", in this model you can have validations that validate each field in the table.