2012-01-19 70 views
0

棘手的问题......respond_with和命名空间

假设以下型号:

class Foo::Bar < ActiveRecord::Base 
class Foo::Nut < ActiveRecord::Base 

以下路线:

namespace :admin do 
    resources :bars do 
    resources :nuts do 

在在坚果创建操作/管理/酒吧/ 100 /坚果,我创建了基于发布数据的模型,并想回应:

@respond_with(:admin, @bar, @nut) (where bar and nut had been set up in the action) 

我带有这个可爱的错误:

NoMethodError (undefined method `admin_foo_bar_foo_nut_url') 

我想轨寻找admin_bar_nut_url而不是admin_foo_bar_foo_nut_url。

任何想法,如果我能解决这个问题?很明显,我的模型定义在模块...

宁愿不得不放弃模型命名空间,但可以,如果我必须。

非常感谢!

+0

我有不同之处在于同样的问题,我的“富”是“管理”你的案件。 – 2016-03-29 16:56:36

回答

0

我不明白你为什么要走开与命名空间,而不是使用的,而不是respond_with的respond_to

respond_to do |format| 
    format.html { redirect_to(admin_bar_nut_url(@bar, @nut)) } 
    end