设计邀请 - 如何向 InvitationsController 添加方法 <设计::InvitationsController

发布于 2024-11-06 08:05:04 字数 838 浏览 5 评论 0 原文

我正在使用 devise invitable gem: https://github.com/scambra/devise_invitable

我的应用程序也是有一个控制器:invitations_controller.rb,其开头为:

class InvitationsController < Devise::InvitationsController

我允许用户注册 FB 并希望向此控制器添加一个方法:

def fb_create
  Rails.logger.info 'fb_createfb_createfb_createfb_createfb_createfb_createfb_createfb_createfb_create'
end

我尝试将其添加到我的routes.rb 文件中,如下所示:

post  "/users/invitation/fb_create" => "invitations#fb_create"

但失败了。如何为此方法添加路线?

目前我的路线一直在使用这个进行设计:

  devise_for :users, :controllers => {:invitations => "invitations", :sessions => "sessions", :registrations => "registrations"}

谢谢

I'm using the devise invitable gem: https://github.com/scambra/devise_invitable

My App also has a controller: invitations_controller.rb, which starts with:

class InvitationsController < Devise::InvitationsController

I'm allowing users to register with FB and would like to add a method to this controller:

def fb_create
  Rails.logger.info 'fb_createfb_createfb_createfb_createfb_createfb_createfb_createfb_createfb_create'
end

I tried adding this to my routes.rb file as so:

post  "/users/invitation/fb_create" => "invitations#fb_create"

But that failed. How can I add a route for this method?

Currently my routes has been using this for devise:

  devise_for :users, :controllers => {:invitations => "invitations", :sessions => "sessions", :registrations => "registrations"}

Thanks

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

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

发布评论

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

评论(1

葬花如无物 2024-11-13 08:05:04
devise_for :users, :controllers => {:invitations => "invitations", :sessions => "sessions", :registrations => "registrations"} do
    post  "/users/invitation/fb_create" => "invitations#fb_create", :as => "invitation_fb_create"
end

这将生成指向该操作的invitation_fb_create_path辅助方法

devise_for :users, :controllers => {:invitations => "invitations", :sessions => "sessions", :registrations => "registrations"} do
    post  "/users/invitation/fb_create" => "invitations#fb_create", :as => "invitation_fb_create"
end

that would generate invitation_fb_create_path helper method pointing to that action

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