Una buena guia de Routes está en:
http://guides.rubyonrails.org/routing.html
Y hace un rato en otro thread dejé el link a una guia de Akita, en el
que incluye una buena explicación y ejemplo de nested resources.
http://akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial
Espero que te sirva, saludos

Damian Garcia.

2009/9/16 Pedro Visintin <[email protected]>:
>
>
> 2009/9/16 Leonardo Otero <[email protected]>
>>
>> Ya que estan tratando el tema de routing, tienen algun buen link donde ver
>> el tema de nested routing?
>>
>>
>> Saludos,
>> Leonardo
>>
>>
>> On 9/16/09, Damian Garcia <[email protected]> wrote:
>>>
>>> Natalia, fijate que para cualquier recurso que quieras acceder de esta
>>> forma:
>>> http://localhost:3004/products/ship
>>> no lo tenés que poner en :member, sinó dentro de collection:
>>> map.resource :products, :collection => {:ship => :get}
>>> para que ande con member entonces deberias de acceder asi
>>> http://localhost:3004/products/1/ship
>>> map.resource :products, :collection => {:ship => :get}
>>>
>>> Saludos,
>>>
>>> Damian Garcia
>>>
>>>
>>> 2009/9/16 Natalia Gutierrez <[email protected]>:
>>> > Hola a todos! una consulta sobre ruteo. Estoy siguiendo el libro Agile
>>> > Web
>>> > Development v2. Tengo un controlador products_controller.rb, al cual le
>>> > agregue una accion "ship":
>>> >
>>> > class
>>> > ProductsController < ApplicationController
>>> >
>>> > def
>>> >
>>> > index
>>> >
>>> > @product_pages
>>> >
>>> > = Product.paginate(:page => params[:page],
>>> >
>>> > :per_page
>>> >
>>> > => 2, :order => 'title ASC')
>>> >
>>> > respond_to
>>> >
>>> > do |format|
>>> >
>>> > format.html
>>> >
>>> > # index.html.erb
>>> >
>>> > format.xml { render
>>> >
>>> > :xml => @products }
>>> >
>>> > end
>>> >
>>> > end
>>> >
>>> > def show
>>> >
>>> > @product
>>> >
>>> > = Product.find(params[:id])
>>> >
>>> > respond_to
>>> >
>>> > do |format|
>>> >
>>> > format.html
>>> >
>>> > # show.html.erb
>>> >
>>> > format.xml { render
>>> >
>>> > :xml => @product }
>>> >
>>> > end
>>> >
>>> > end
>>> >
>>> > ...
>>> >
>>> > def
>>> >
>>> > ship
>>> >
>>> > @pending_orders
>>> >
>>> > = Order.pending_shipping
>>> >
>>> > end
>>> >
>>> > end
>>> >
>>> > Y este es mi archivo routes.rb:
>>> >
>>> > ActionController::Routing::Routes.draw
>>> >
>>> > do |map|
>>> >
>>> > map.resources
>>> >
>>> > :products
>>> >
>>> > map.connect
>>> >
>>> > ':controller/:action/:id'
>>> >
>>> > map.connect
>>> >
>>> > ':controller/:action/:id.:format'
>>> >
>>> > end
>>> >
>>> >
>>> >
>>> > El tema es que cuando quiero acceder con
>>> > http://localhost:3004/products/ship
>>> > , me tira el error:
>>> >
>>> > ActiveRecord::RecordNotFound in ProductsController#show  Couldn't find
>>> > Product with ID=ship
>>> >
>>> > es decir, me esta tomando ship como parametro y no como funcion. Probe
>>> > colocando:
>>> >
>>> > map.resource :products, :member => {:ship => :get}, pero si lo coloco
>>> > antes
>>> > de map.resources :products, me deja de funcionar el resto... y si lo
>>> > coloco
>>> > despues no hace nada.
>>> >
>>> > Espero respuestas.... Gracias
>>> >
>>> >
>>> >
>>> > Natalia Gutiérrez
>>> > Ingeniería y Desarrollo
>>> > ICOP Santa Fe S.R.L.
>>> > Primera Junta 3057
>>> > S3000CDM - Santa Fe
>>> > (0342) 4526057 int. 140
>>> > [email protected]
>>> >
>>> > __________ Información de ESET NOD32 Antivirus, versión de la base de
>>> > firmas
>>> > de virus 4430 (20090916) __________
>>> >
>>> > ESET NOD32 Antivirus ha comprobado este mensaje.
>>> >
>>> > http://www.eset.com
>>> >
>>> > _______________________________________________
>>> > Ruby mailing list
>>> > [email protected]
>>> >
>>> > http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
>>> >
>>> >
>>> _______________________________________________
>>> Ruby mailing list
>>> [email protected]
>>> http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
>>
>>
>> _______________________________________________
>> Ruby mailing list
>> [email protected]
>> http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
>>
>
> A los que esten con el tema de routes.rb sugiero lean sobre REST (alguien
> que pase referencias?), entiendan bien el concepto y se les va a simplificar
> el tema de routes.rb
>
> Saluti
>
> P
>
> --
> Pedro   Visintin . S o f t w a r e   A r c h i t e c t
> http://www.pedrovisintin.com
>
> Ruby On Rails Argentina. http://blogs.onrails.com.ar
>
> Personal page:
> http://www.p-e-t-e-r-p-u-n-k.com.ar
>
> "Lo que hagas, hacelo con pasión"
>
>
> _______________________________________________
> Ruby mailing list
> [email protected]
> http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar
>
>
_______________________________________________
Ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a