我試圖在使用鍊金術CMS框架的Rails站點內建立留言模塊。用Alchemy構建模塊的文檔看起來並沒有太多的東西,所以我只是從this page開始。爲Alchemy CMS創建自定義留言簿模塊
我創建了兩個控制器,一個管理員會使用名爲guestbook_controller.rb下的應用程序/控制器/管理放在這個
module Admin
class GuestbookController < Alchemy::Admin::ResourcesController
def index
"index"
end
end
end
,另一個客人在應用/控制器/ guestbook_controller.rb訪問
class GuestbookController < ActionController::Base
def index
"index"
end
end
我的本意是,留言帖子都已經內鍊金術和一個表單頁面的一個下顯示也將被顯示在此頁面上。
的留言模型如下這樣:
class GuestbookEntry < ActiveRecord::Base
attr_accessible :location, :message, :name
end
我的路線文件如下所示:
resources :guestbook
namespace :admin do
resources :guestbook
end
mount Alchemy::Engine => '/'
,我有一個config目錄下,看起來像被稱爲authorization_rules.rb文件: 授權做
role :admin do
has_permission_on :guestbook, :to => [:manage]
end
end
第一個問題我遇到的是去route/admin/guestbook給我的錯誤'你沒有授權',但授權規則文件應該由我的initalizer調用,所以爲什麼我得到這個錯誤?
# Registering guestbook module in Alchemy CMS
Alchemy::Modules.register_module(YAML.load_file(File.join(File.dirname(__FILE__), '../..', 'config/guestbook_module.yml')))
# Loading authorization rules and register them to auth engine instance
Alchemy::AuthEngine.get_instance.load(File.join(File.dirname(__FILE__), '../..', 'config/authorization_rules.rb'))