map.resources

Hi
   From a rails 2.0 tutorial i read when I do ruby script/generate
scaffold Album
then in routes.rb file an entry like
map.resources :albums
     be there..I am using rails 1.2.5 but did not see any such entry
after scaffold in routes.rb. Is that happens to rails 2.0 onwards

Thanaks in advance
Sijo

Yes, that’s for Rails 2.x.

So Can't I use REST with rails 1.2.5 ?

So Can't I use REST with rails 1.2.5 ?

You certainly can - full REST support was added in 1.2.0.

But the scaffold generator in 1.2 is still the "old" scaffold
generator that's not REST-aware.

Instead, just use script/generate scaffold_resource Album

The scaffold_resource generator was renamed to simply "scaffold" in
Rails 2.0.

Hope this helps?

Jeff
Oct 4, 2008, Austin, TX: http://www.purpleworkshops.com/workshops/rest-and-web-services

Hi
    Thanks for yur reply.so you are saying that after I do
script/generate scaffold_resource Album then in my routes.rb will
contain
map.resources :albums
  Then could you please correct me if anything wrong in the following
steps?(This I am doing for learning REST in Rails)
   After creating a rails application I did ruby script/generate model
Item
   then in db/migrate/001_create_items.rb I added
  t.column :name, :string, :limit=>40 etc and migrated.
  Then I did rake db:migrate
  After that as you said ruby script/generate scaffold_resource Item
(Hre first I did just scaffold do u remember?)
       But at the last line it says that db/migrate create_items already
exists..So surely that step failed Isn't it? And sure there is no change
in routes.rb (As i expect map.resources :items)

       Could you please tell me where error happened in my steps?

Thanks in advance
Sijo

Hi
Thanks for yur reply.so you are saying that after I do
script/generate scaffold_resource Album then in my routes.rb will
contain
map.resources :albums

Yes - give it a try :slight_smile:

Then could you please correct me if anything wrong in the following
steps?(This I am doing for learning REST in Rails)
After creating a rails application I did ruby script/generate model
Item
then in db/migrate/001_create_items.rb I added
t.column :name, :string, :limit=>40 etc and migrated.
Then I did rake db:migrate
After that as you said ruby script/generate scaffold_resource Item
(Hre first I did just scaffold do u remember?)
But at the last line it says that db/migrate create_items already
exists..So surely that step failed Isn't it? And sure there is no change
in routes.rb (As i expect map.resources :items)

Ah, that's because scaffold_resource creates the model for you as
well. If you already have a model, pass --skip to make it not
overwrite your files.

Also, it's not obvious, but you can start up any generator without any
parameters to get help on it, for example:

script/generate scaffold

This will emit a short list of options you can use with the scaffold
generator.

Jeff

Oct 4, 2008, Austin, TX: http://www.purpleworkshops.com/workshops/rest-and-web-services