0
,我想有一个像下方的路由前缀:前缀PARAM轨我使用Rails3中路线
我在我的路线如下:
require 'resque/server'
Woofound::Application.routes.draw do
scope "/:my_param" do
resource :users
end
end
然后,我已在在关注我应用控制器:
class ApplicationController < ActionController::Base
before_filter :check_param
private
def check_param
unless Myobject.find_by_param(param[:my_param])
raise "You must add this param"
end
end
end
然后在我的路线我想有能够无需做
访问user_path(@user)user_path(:param_for_route_name_spacing, @user)
如果你需要更清晰的话让我知道。
简而言之,我想为自己的路由设置一个参数化前缀,该参数会自动传递回参数化命名空间,而不必将其作为第一个参数添加到对象路径中。
现在我得到这个错误超:没有超类方法'user_path' –
OK,你的路由文件应该有'资源:users'不'资源:users'并调用'是helper_method:user_path'在控制器中。 – bgates
我不小心把:as =>:something_else放在我的路线中 你的修复是完美的,非常感谢你 –