데이터베이스 구조를 기반으로 GUI를 빌드하기 위해 activescaffold가있는 루비 온 레일 앱이 있습니다. 사용자에게는 역할이 있으며 각 역할은 권한 집합입니다. 각 권한은 사용자가이 컨트롤러에서 수행 할 수 있는지 여부와 컨트롤러의 조합입니다.루비 온 레일 (well-on-rails)의 도우미 컬럼 오버라이드
# DATABASE!
create_table :rights do |t|
t.column :controller, :string, :limit => 32, :null => false
t.column :action, :string, :limit => 32, :null => false
end
create_table :rights_roles, :id => false do |t|
t.column :right_id, :integer
t.column :role_id, :integer
end
create_table :roles do |t|
t.column :name, :string, :limit => 32, :null => false
end
#MODELS!
class Role < ActiveRecord::Base
has_and_belongs_to_many :rights
class Right < ActiveRecord::Base
has_and_belongs_to_many :roles
# ROLE CONTROLLER!
class RoleController < ApplicationController
active_scaffold :role do |config|
config.columns = Array[:name, :rights]
config.columns[:rights].form_ui = :select
나는 현재 (옵션 구성되지 않은 더 많은 활동이있을 것, 그것은 무서운 것 때문에.) 불편 역할에 대한 편집 창 다음 한
:
http://postimage.org/image/4e8ukk2px/
내가 원하는을 다음과 같은 도우미 메소드를 작성하십시오.
module RoleHelper
def rights_form_column (record, input_name)
...
end
end
"권한"컬럼에 대한 입력 메소드를 지정하는 양식을 정의하는 데 필요합니다. 그러나 나는 그것을 쓰는 방법을 모른다. 바람직한 형태는 다음과 같습니다
administration
action1(checkbox)
action2(checkbox)
configuration
action1(checkbox)
...
내가 그 activescaffold이 오래 알고,하지만 난 그것을 사용하는이 ... 도와주세요!