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
我厌倦了它使用它和无块。我希望该范围内的“程序”总数作为最终结果。
尽管我从来没有使用过它,但我已经看过它的文档,并且似乎模型完全由框架管理。和“范围”一词可以自己冲突 “范围”,一个过滤器屏幕。我总是避免使用框架或插件,如果我可以自己做 –