我试图创建一个动态网址,它会通过它传递参数。 我的代码看起来像这样:
def self.mailer(user)
url = user_UserByEmail_url(user.user_token)
@text = "#{url} click here to navigate"
subject = "Hello World"
mail(subject: subject, to: ###)
end
然后在我的routes.rb看起来像那样:
resources :users, only: [] do
collection do
get :UserByEmail
end
end
并且,在我的用户控制器中,我有以下功能:
before_filter :find_userEmail
def find_userEmail
@user = User.find_by_user_token(params[:id])
end
def UserByEmail
url = "#{GLOBAL[:url]}/champion_declined//#{companyToken}"
redirect_to url
end
但是,当我使用:url = user_UserByEmail_url(user.user_token)
我收到了错误:
未定义的方法`user_UserByEmail_url'