もくもく開始
最近は近所の喫茶店 (電源、wifi 完備) にてもくもくがトレンドらしいですが、休日は家事諸々があり、わしは自宅で作業開始。
とりあえず RoR な認証云々について確認の方向。stackoverflow によると
AuthLogic appears to be the new kid on the block and seems to be the next evolution of restful_authentication, easier to use, etc
http://github.com/binarylogic/authlogic/tree/master
Edit: now that Rails 3 is out, Devise seems to be the new, new kid on the block
https://github.com/plataformatec/devise
Ruby Toolbox is a great site for finding the current best solution in various categories (based on the number of GitHub watchers):
http://ruby-toolbox.com/categories/rails_authentication.html
とのこと。devise とかってどこかで耳にした記憶がなんとなくあります。
ちなみに gem search したら死ぬほど出てきました。
$ gem search devise -r charanya-devise_ldap_authenticatable (0.4.6) dcu-devise (1.0.7) devise (1.4.7) devise-french (1.0.2) devise-links (0.2.3) devise-login-cookie (0.1.2) devise-mongo_mapper (0.0.2) devise-neo4j (1.0.3) devise-russian (1.4.7.3) devise-spec (0.1.3) devise-twitter (0.1.1) devise_active_directory_authenticatable (0.4.1) devise_aes_encryptable (0.2.3) devise_authenticator (0.0.3) devise_autosigninable (1.0.1) devise_bushido_authenticatable (1.0.0) devise_certifiable (0.1.0) devise_couch (0.1.2) devise_couch_potato (0.0.2) devise_ennder (1.4.1.0.9)
なんか devise-twitter などという非常にみりょく的なナニがありますな。ま、それは良いとしてこの度確認しておきたいのは、認証云々はソレとして、拡張できるかどうか、と言えば良いでしょうか。
とりあえずプロジェクト作成して云々してみます。
$ rails new devise-sample (出力略 $ cd devise-sample $ gem install devise -r Fetching: warden-1.0.6.gem (100%) Fetching: orm_adapter-0.0.5.gem (100%) Fetching: bcrypt-ruby-3.0.1.gem (100%) Building native extensions. This could take a while... Fetching: devise-1.4.7.gem (100%) Successfully installed warden-1.0.6 Successfully installed orm_adapter-0.0.5 Successfully installed bcrypt-ruby-3.0.1 Successfully installed devise-1.4.7 4 gems installed Installing ri documentation for warden-1.0.6... Installing ri documentation for orm_adapter-0.0.5... Installing ri documentation for bcrypt-ruby-3.0.1... Installing ri documentation for devise-1.4.7... Installing RDoc documentation for warden-1.0.6... Installing RDoc documentation for orm_adapter-0.0.5... Installing RDoc documentation for bcrypt-ruby-3.0.1... Installing RDoc documentation for devise-1.4.7... $
で、以下か。
$ rails generate devise:install Could not find generator devise:install. $
あ、Gemfile に云々とありますね。Gemfile を以下にして
source 'http://rubygems.org' gem 'rails', '3.0.9' gem 'sqlite3' gem 'devise'
で、リトライ。
$ rails generate devise:install create config/initializers/devise.rb create config/locales/devise.en.yml =============================================================================== Some setup you must do manually if you haven't yet: 1. Setup default url options for your specific environment. Here is an example of development environment: config.action_mailer.default_url_options = { :host => 'localhost:3000' } This is a required Rails configuration. In production it must be the actual host of your application 2. Ensure you have defined root_url to *something* in your config/routes.rb. For example: root :to => "home#index" 3. Ensure you have flash messages in app/views/layouts/application.html.erb. For example: <p class="notice"><%= notice %></p> <p class="alert"><%= alert %></p> =============================================================================== $
で、以下?
$ rails generate devise User invoke active_record create db/migrate/20111009074113_devise_create_users.rb create app/models/user.rb invoke test_unit create test/unit/user_test.rb create test/fixtures/users.yml insert app/models/user.rb route devise_for :users $
ここまでで出力されたソレ達の中身を確認してみることに。
とりあえず
夕飯作成担当とのことにて対応はメシ後となります。