LoginEngine
まず、インストール。
./script/plugin install http://svn.rails-engines.org/plugins/engines ./script/plugin install http://svn.rails-engines.org/plugins/login_engine
これでインストール完了。通常は
rake engine_migrate ENGINE=login
を実行するらしいのだが、手で書き直したいので、
vendor/plugins/login_engine/db/migrate/001_initial_schema.rb
をdb/migrateにコピーして、編集する。
モデルはすでにlogin_engineに存在しているので、generate modelはしない。
environment.rbの下に追加
module LoginEngine config :salt, "hakatano" # config :use_email_notification, false config :email_from, "webmaster@e-kenkyu.com" config :admin_email, "admin@e-kenkyu.com" config :app_name,'Conference' config :app_url, 'http://sv5.rabbix.jp:3004' end Engines.start :login
ApplicationControllerに追加。以下のようにすると全てのページで
ログインが必要になる。onlyやexeptをつかって個別の制御する。
require 'login_engine' class ApplicationController < ActionController::Base include LoginEngine helper :user model :user before_filter :login_required end
ApplicationHelperに追加。
module ApplicationHelper include LoginEngine end
config/environments/development.rbに追加
ActionMailer::Base.server_settings = { :address => "localhost", :port => 25, :domain => "e-kenkyu.com"#, # :user_name => "<your user name here>", # :password => "<your password here>", # :authentication => :login }
以上で動くようになった。いろいろはまった。