简体   繁体   English

为什么在Rails邮件程序中为帐户激活电子邮件使用“编辑” URL?

[英]Why use an “edit” url for an account activation email in a rails mailer?

I'm at the point in the Hartl tutorial ( chapter 11.2.1 ) where you create an account activation mailer and I was wondering, why are we creating an "edit" url like this: 我在Hartl教程( 第11.2.1节 )中创建了一个帐户激活邮件程序,我想知道为什么我们要创建一个“ edit” URL,如下所示:

<%= edit_account_activation_url(@user.activation_token, email: @user.email) %>

http://www.example.com/account_activations/q5lt38hQDc_959PVoo6b7A/edit

It seems like "edit" is not the right word for this. 似乎“编辑”不是正确的词。 To me it would make more sense to use a method called something like "activate" instead "edit". 对我来说,使用一种叫做“激活”而不是“编辑”的方法更有意义。

Why is Hartl using "edit"? 为什么Hartl使用“编辑”? I suspect it's because that is RESTful way to do it? 我怀疑这是因为这是RESTful方式吗? Such as in this edit_user_url(user) . 例如在此edit_user_url(user)

Here are the routes that the mailer is using: 这是邮件程序使用的路由:

resources :account_activations, only: [:edit]

Can anyone explain why he might be using "edit"? 谁能解释为什么他可能会使用“编辑”?

Well practically activation of account, changes it. 好吧,实际上是激活帐户,将其更改。 So from rest point of view you editing it. 因此,从休息的角度来看,您可以对其进行编辑。

If you want to be more verbose in terms of purpose, you could alias this route to activate using as method :as documentation 如果您希望在用途方面更详细,则可以使用as方法:as documentation将此路径别名化以激活

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM