----
Dwayne Macgowan
Sent from mobile
On 16/09/2009, at 12:02, 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
Uh, yo había resuelto esto de una manera horrrrrible.
esta lista es la bomba
_______________________________________________
Ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar