0
我使用活動管理與ActiveRecord範圍。不過,我在添加範圍時遇到了問題。活動管理範圍不起作用1.0.0.pre2
運行紅寶石2.2.1p85(2015年2月26日修訂49769)x86_64的Linux的]和 Rails的4.2.5.1
#app/model/accounts.rb
class Account < ActiveRecord::Base
searchkick
belongs_to :program
belongs_to :insurance
has_many :notes
scope :program_name, -> (program) {where(program_name: adult) }
validates :first_name, :last_name, :address, :phone, presence: true
validates :phone, format: { with: /\A\d{3} \d{3}-\d{4}\z/,
message: "must be in the format 123 456-7890" }
end
我希望能夠給我們在這個應用程序/管理/賬戶.rb
#app/admin/account.rb
ActiveAdmin.register Account do
menu :priority => 2
permit_params :first_name, :last_name, :return_client, :program_id, :insurance_id, :address, :phone
index do
column :first_name
column :last_name
column :address
column :phone
column :created_at
column :return_client
column :program
column :insurance
actions
end
scope :all, :default => true
scope :adult, default: true do |accounts|
accounts.program_name('adult')
end
end
我厭倦了它使用它和無塊。我希望該範圍內的「程序」總數作爲最終結果。
儘管我從來沒有使用過它,但我已經看過它的文檔,並且似乎模型完全由框架管理。和「範圍」一詞可以自己衝突 「範圍」,一個過濾器屏幕。我總是避免使用框架或插件,如果我可以自己做 –