【发布时间】:2015-04-06 03:58:57
【问题描述】:
我正在编写一个 Rails 引擎。
我在应用程序控制器的 gem 中有两种方法(authenticate 和 current_user)。 https://github.com/krunal/aadhar/blob/master/app/controllers/aadhar/application_controller.rb
我希望 'authenticate' 方法应该在父 Rails 应用程序中作为 before_filter 提供。
我希望 'current_user' 方法应该在父 Rails 应用程序中作为方法和助手可用。
我不知道如何才能做到这一点。
假设在我的父应用程序中,我有一个帖子控制器。我想以这种方式使用 'authenticate' 和 'current_user'。
PostsController < ApplicationController
before_filter :authenticate
def index
current_user.posts
end
【问题讨论】:
标签: ruby-on-rails ruby gem rails-engines