Ruby On RailsにLoginEngineの設定の続き
Ruby On RailsにLoginEngineの設定の続き
あとはデータベースの設定と、アプリケーションの設定。
■データベースの設定
Eclipseを使ってジェネレーターを起動
ここは素直にすすんでくれて一安心。
■アプリケーションの設定
まずは"/app/controllers/application.rb"に下記のように追記
require 'login_engine'
class ApplicationController < ActionController::Base
include LoginEngine
helper :user
require_dependency 'user'
before_filter :login_required
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => 'b80465322633a10f76a0e67dc7bfde1f'
end
※太字の部分が追記箇所です。
ここで味噌となるのが
require_dependency 'user'
書籍やサイトには
model 'user'
と書けと書いてあったのですが、Rails2.0よりこの書き方だた動かないようです。
次に"/app/helpers/application_helper.rb"に下記のように追記
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
include LoginEngine
end
※太字の部分が追記箇所です。
これで動くはず!!と勇みブラウザからアクセスしてみたのですがここでエラー画面に。
調べていくと、
/vendor/plugins/login_engine/app/controllers/user_controller.rb
の中に、上で書いた
model 'user'
という記述があるではないですか。
class UserController < ApplicationController
#model 'user'
require_dependency 'user'# Override this function in your own application to define a custom home action.
def home
・
・
・
プラグインのソースを直さないといけないのかと、激しい失意の中上記の修正を行い、何とか動くように。
これでプラグインソースをいじるのは終わりにしたい
そう思っていたわけですが、この修正が序章に過ぎないことをこ時私はまだ知りませんでした(>_<)
というわけで、続きは次のページで。
########################################################
◎LoginEngineの導入
其の壱 http://d.hatena.ne.jp/sai-ou89/20080401
其の弐 http://d.hatena.ne.jp/sai-ou89/20080402
其の参 http://d.hatena.ne.jp/sai-ou89/20080403
其の四 http://d.hatena.ne.jp/sai-ou89/20080404
其の五 http://d.hatena.ne.jp/sai-ou89/20080604
########################################################