到 Rails 3 从 Rails 2 路由

发布于 2024-11-03 05:29:27 字数 770 浏览 8 评论 0原文

我正在按照本教程发送激活电子邮件:

http://www.slideshare.net /JamesEdwardGrayII/sending-email-with-rails

我相当确定这是使用 Rails 2 完成的,并且路由对我来说有点问题。

routes.rb:

map.activate "activate/:token", :controller => "activations", :action => "create"

启用:

activate_url(:token => @user.perishable_token, :host => "localhost:3000")

以便发送 localhost:3000/:token url 供用户激活。

为了使其适用于 Rails 3,我尝试了以下操作:

match 'activate/:token' => 'activations#create'
match 'activate/:token', :to => 'activations#create'

activate_url 不起作用。我希望得到一些意见。谢谢!

I am following this tutorial on sending activation email:

http://www.slideshare.net/JamesEdwardGrayII/sending-email-with-rails

I am fairly certain this was done with rails 2 and the routing has been a little problematic for me.

routes.rb:

map.activate "activate/:token", :controller => "activations", :action => "create"

enables:

activate_url(:token => @user.perishable_token, :host => "localhost:3000")

So that localhost:3000/:token url is sent for the user to activate.

In order to make it work for rails 3, I have tried the following:

match 'activate/:token' => 'activations#create'
match 'activate/:token', :to => 'activations#create'

but activate_url isn't working. I'd appreciate some input. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九八野马 2024-11-10 05:29:27

在您的routes.rb中添加:as =>; 'activate' 到您的 match 方法,如下所示:

match 'activate/:token' => '激活#create', :as => 'activate' 如果您只使用 GET/POST,我会将路由更改为:

对于 GET:

get 'activate/:index' => '激活#create', :as => 'activate'

或用于 POST

post 'activate/:index' => '激活#create', :as => '激活'

In your routes.rb add a :as => 'activate' to your match method like this:

match 'activate/:token' => 'activations#create', :as => 'activate' and if you are only using GET/POST I'd change the route to this:

For GET:

get 'activate/:index' => 'activations#create', :as => 'activate'

or for POST

post 'activate/:index' => 'activations#create', :as => 'activate'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文