Ruby 计算rails路线,获取我的详细信息路径的未定义方法

Ruby 计算rails路线,获取我的详细信息路径的未定义方法,ruby,ruby-on-rails-3.2,routes,Ruby,Ruby On Rails 3.2,Routes,我的数据表数据: def data theusers.map do |usermap| [ h(usersmap.spriden_last_name), h(usermap.spriden_first_name), h(usermap.spriden_id), link_to(usermap.gobtpac_username, detail_path(usermap.spriden_id)) ]

我的数据表数据:

def data
    theusers.map do |usermap|
      [
        h(usersmap.spriden_last_name),
        h(usermap.spriden_first_name),
        h(usermap.spriden_id),
        link_to(usermap.gobtpac_username, detail_path(usermap.spriden_id))
      ]
    end
end
上述代码位于
app\datatables\helpdesk\u datatable.rb

上面的工作主要是我知道它正在获取数据,我得到的错误是细节路径

细节路径的“未定义方法”错误…
这意味着它没有动态构建路由器,对吗

或者我传递了错误的东西,我试图传递usermap.spriden.id,只是横幅用户,同样的问题。显然,我真的不确定路线是如何工作的。我在控制器中有一个details_controller.rb,其中有一个show方法,我有views/details/show.html.erb,它将显示传递到路由中的数据,至少我认为是这样。但它只是一个ID还是一个对象?所以如果它只是一个id,我必须在 表演方法对吗?这样的路线看起来怎么样?我也在使用Desive和cancan这是我的路由文件:

NmsuMyaccount::Application.routes.draw do
 authenticated :user do
   root :to => 'home#index'
   match 'home', :to => 'home#index', :via => :get 
 end


 #get 'show-details' => "details#show", as: 'show_details'

 resources :details
 devise_for :users
 resources :users
 # In order for an unauthorized user access this controller#action, this needs to be in  a scope, but I don't know why.
 devise_scope :user do
   match 'home', :to => 'home#index', :via => :get
 end

end

同时到达终点localhost:3000是一个错误,我必须转到/home,尽管designe可以正常工作。所以我认为我很接近,但我一生都无法获得详细信息路径,我认为这是一个多重问题,所以尝试了详细信息,只是没有详细信息路径等等。没有骰子。

我不相信您可以访问Rails在自定义类中提供的路由帮助程序。因此,您必须在类中手动包含该模块。比如:

link_to(usermap.gobtpac_username, Rails.application.routes.url_helpers.detail_path(usermap.spriden_id))
或:

有关主题的更多信息,请参见此处:

我认为您无法访问Rails在自定义类中提供的路由帮助程序。因此,您必须在类中手动包含该模块。比如:

link_to(usermap.gobtpac_username, Rails.application.routes.url_helpers.detail_path(usermap.spriden_id))
或:

有关主题的更多信息,请参见此处:

伙计,就是这样,很高兴知道我没有完全失去理智,错过了这个。谢谢在这个rails框架中,作用域有时会让我绊倒。我确实尝试了第二种使用include的方法,它给了我一个“SystemStackError:stack level To deep”错误,所以尝试了前面的建议,效果非常好。我猜包括整个Rails.application.routes.url\u helpers会导致某种递归发生。伙计,就是这样,很高兴知道我没有完全失控,错过了这个。谢谢在这个rails框架中,作用域有时会让我绊倒。我确实尝试了第二种使用include的方法,它给了我一个“SystemStackError:stack level To deep”错误,所以尝试了前面的建议,效果非常好。我猜包括整个Rails.application.routes.url\u helpers都是为了实现某种递归。