Hey Richard,
Long time no speak…
On Dec 3, 8:51 pm, RichardOnRails
[email protected] wrote:
Question: Is that “map.resources :csvs” at the beginning useless, or
does it serve some purpose?
Here’s where I find scaffolding most useful - it gives you a picture
of how the different RoR components play together.
rails -d postgresql test
cd test
script/generate scaffold Document title:string synopsis:string
body:text author:string
Now you can sniff out one way that MVC splits the processing in RoR
just by perusing the newly created files built in support of your
Document model.
But, to your specific question:
grep documents config/routes.rb ==> map.resources :documents
When in doubt, rake it out…
rake routes
(in /Users/rick/test)
documents GET /documents
{:controller=>“documents”, :action=>“index”}
formatted_documents GET /documents.:format
{:controller=>“documents”, :action=>“index”}
POST /documents
{:controller=>“documents”, :action=>“create”}
POST /documents.:format
{:controller=>“documents”, :action=>“create”}
new_document GET /documents/new
{:controller=>“documents”, :action=>“new”}
formatted_new_document GET /documents/new.:format
{:controller=>“documents”, :action=>“new”}
edit_document GET /documents/:id/edit
{:controller=>“documents”, :action=>“edit”}
formatted_edit_document GET /documents/:id/edit.:format
{:controller=>“documents”, :action=>“edit”}
document GET /documents/:id
{:controller=>“documents”, :action=>“show”}
formatted_document GET /documents/:id.:format
{:controller=>“documents”, :action=>“show”}
PUT /documents/:id
{:controller=>“documents”, :action=>“update”}
PUT /documents/:id.:format
{:controller=>“documents”, :action=>“update”}
DELETE /documents/:id
{:controller=>“documents”, :action=>“destroy”}
DELETE /documents/:id.:format
{:controller=>“documents”, :action=>“destroy”}
/:controller/:action/:id
/:controller/:action/:id.:format
map.resources :your_model_pluralized gives you many url_for and
path_for routes that can be used to hook up with
specific :controller :action [:id]. You’ll see examples of use in the
scaffold generated controller and views.
Can I shoehorn in a related question?
I want to add another link in index.html.erb. I want to RESTfully
invoke load_cvs_filenames in the csvs controller. Is that simple to
write?
It’s not clear to me what you’re after here. Any more thoughts?
Rick