【问题标题】:Rails 4 activeadmin - undefined local variable or method `view_factory' for :Arbre::ContextRails 4 activeadmin - 未定义的局部变量或方法“view_factory”:Arbre::Context
【发布时间】:2014-09-10 15:21:22
【问题描述】:

我正在为我的管理界面使用 activeadmin gem,现在我创建了一个新控制器并添加了布局“acitveadmin”

我收到以下错误

NameError in MeetingRooms#index

Showing /home/amp/.rvm/gems/ruby-2.1.1@rails4.1/bundler/gems/active_admin-41d5176f3682/app/views/layouts/active_admin.html.arb

第 2 行提出的地方:

undefined local variable or method `view_factory' for :Arbre::Context

我的控制器是
app/controllers/meeting_rooms_controller.rb

class MeetingRoomsController < ApplicationController
  layout 'active_admin'
  def index
    @meeting_rooms = MeetingRoom.all  
    #render :layout => "active_admin"
  end
end

谁能帮帮我。

【问题讨论】:

    标签: activeadmin ruby-on-rails-4.1


    【解决方案1】:

    我认为你应该使用控制器块来定义动作。

    https://github.com/activeadmin/activeadmin/blob/master/docs/8-custom-actions.md#modifying-the-controller

    ActiveAdmin.register MeetingRoom do
    
      controller do
        # This code is evaluated within the controller class
    
        def define_a_method
          # Instance method
        end
      end
    
    end
    

    在控制器块中,您可以使用 InheritedResources 的功能。 https://github.com/josevalim/inherited_resources#overwriting-actions

    【讨论】:

      猜你喜欢
      • 2014-07-06
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多