水曜日, 7月 22nd, 2009
今年は久しぶりにお盆に帰郷します。
貴重な香川時間なんですが、半分は実家の家族と過ごさず会社の後輩と一緒に、プライベートな開発合宿を計画中です。
日時はほぼ決まったので、現在場所を選定中なのですが、香川県で探すとなかなか難しいですね。
・山奥行くと温泉はあるけどネット環境がイマイチ
・町中でるとネット環境はあるけど、ビジネスホテルばっかりで雰囲気がイマイチ
というジレンマに悩んでおりました。
ところが、タスケさんからなかなかナイスなお宿の紹介がありまして、かなり心が動かされております。
やっぱり旅行と一緒でこういう計画を立てている時が一番おもしろいですね。
■参考リンク
kaihachu.com – 開発合宿好きの技術者のためのコミュニティブログ
http://kaihachu.com/
Tags: Ruby on Rails
Posted in 徒然 | No Comments »
月曜日, 11月 24th, 2008
user
モデル名。同じ名前で登録関係のコントローラも作成される。以前のデフォルトでは、userモデルと登録のためのaccountコントローラだったけど、今回は両方とも同じ名前で作られる
sessions
ログインログアウト用コントローラ名。ログイン情報自体を一つのリソースとしてみなしているんだね。面白い。
–include-activation
メール認証を行うかどうか。最初の登録は仮登録で、届いたメールに書かれてるアドレスにアクセスすると登録が完了するってやつだね。以前は公式でやり方は 紹介されていたけど、自分で実装する必要があった部分。でもobserver使うやり方は好きじゃないので、うちでは使ってなかった
–stateful
プラグインacts_as_state_machineを使ってユーザの状態管理をする。仮登録状態とか、正会員とか、退会とかね。そんな状態をいくつか 定義しておいて、状態Aから状態Bに変わった時にはCという処理を行う、といったことをacts_as_state_machineを使うことで簡潔に書 くことができる。利用には別途acts_as_state_machineのインストールが必要
Tags: Ruby on Rails
Posted in Programing | No Comments »
月曜日, 11月 24th, 2008
[sourcecode language='ruby']
class AddPrice < ActiveRecord::Migration
def self.up
add_column :products, :price, :decimal, :precision => 8, :scale => 2, :default => 0
end
def self.down
remove_column :products, :price
end
end
[/sourcecode]
————————————————-
■self.up
追加メソッド
productsテーブルに、price列を、decimal型で生成。有効桁数は8桁、小数点以下は2桁。デフォルト値は0
■self.down
削除メソッド
price列を削除
■入力の妥当性検査
モデル側で定義
以下のソースを追加
[sourcecode language='ruby']
validates_presence_of :title, :body
[/sourcecode]
※”vp”入力語、tabで置換
Tags: Ruby on Rails
Posted in Programing | No Comments »
月曜日, 11月 24th, 2008
■プロジェクト作成
Netbeansウィザードから作成
■モデル作成
モデル→「生成」から作成。引数指定しておくとマイグレーション用のファイルも同時に生成される。
例)
名前欄に以下を入力
Product title:string description:text image_url:string
■マイグレーションファイルの編集
モデルを作成時にマイグレーションファイルも作成される。
カラム追加する必要がある場合などはこちらで追加
■マイグレーション実行
プロジェクト名→データベースマイグレーションで、DB管理
rake db:migrate
とかを裏で実行している。
■コントローラ作成
コントローラ→「生成」から作成。作成時にコントローラ名を入力
例)
Admin
※AdminControllerクラスを作成
生成されるadmin_controller.rbファイル内に
scaffold :<モデル名>
だけでも、とりあえずモデルの管理するテーブルをコントロールする土台(scaffold)アプリケーションは生成される。
ただしこの記法は動的scaffold。
■ルートの変更
構成(config)フォルダ内の、routes.rbで以下を編集
#? map.connect ”, :controller => “welcome”
↓
map.connect ”, :controller => “admin”
公開(public)フォルダ内の、index.htmlを削除
※このファイルが最優先されるため。
■実行
F6キーでWEBrickが立ち上がり、検証可能
■属性(カラム)の追加
データベースマイグレーション→「生成」でマイグレーションファイルを追加
名前欄には、このマイグレーションファイルが何を追加するものか書くとわかりよい
例)
AddPrice
※価格を追加
生成されたマイグレーションファイルに追加列情報を記述
Tags: Netbeans, Ruby on Rails
Posted in Programing | No Comments »
月曜日, 11月 24th, 2008
モデル(product.rb)に標準検証メソッドを追加
●入力値が空で無いかの判定
validates_presence_of :title, :description, :image_url
:title, :description, :image_urlカラムが空だとNG判定
●数値入力かの判定
validates_numericality_of :price
:priceカラムが空だとNG判定
●重複チェック
validates_uniqueness_of :title
:titleカラム内容が重複している場合はNG
●入力文字列のフォーマット判定
validates_format_of :image_url, :with => %r{\.(gif|jpg|jpeg|png)$}i, :message => “はGIF、JPEG、PNG画像のURLでなければなりません”
:image_urlカラムの入力文字列に、.gif,.jpg,.jpeg,.pngが入ってないとNG
●正の数判定
protected
def validate
errors.add(:price, “は最低でも0.01以上でなければなりません”) if price.nil? || price < 0.01
end
price列への入力数値が、空でないかもしくは0.01以上かの判定
Tags: Ruby on Rails
Posted in Programing | No Comments »
月曜日, 11月 24th, 2008
コントローラ→「生成」で、生成引数に scaffold を選択。モデル名とコントローラー名をそれぞれ入力
例)今回の場合
モデル名:Product
コントローラ名:Admin
ファイルがすでにある場合。は、上書きを選択しておく。
Tags: Ruby on Rails
Posted in Programing | No Comments »
火曜日, 8月 26th, 2008
■4. ジェネレータコマンド「authenticated」 が追加されるので、実行
activationもstateful も入れる
$ ./script/generate authenticated user sessions
-?include-activation
-?stateful
こんな感じ。
C:Documents and SettingsMiyaiMy DocumentsNetBeansProjectsrubyweblog>ruby sc
ript/generate authenticated user sessions –include-activation –stateful———————————————————————-
Don’t forget to:map.activate ‘/activate/:activation_code’, :controller => ‘users’, :action =
> ‘activate’- add an observer to config/environment.rb
config.active_record.observers = :user_observerAlso, don’t forget to install the acts_as_state_machine plugin and set your reso
urce:svn export http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/tr
unk vendor/plugins/acts_as_state_machineIn config/routes.rb:
map.resources :users, :member => { :suspend => :put, :unsuspend => :put, :purg
e => :delete }Try these for some familiar login URLs if you like:
map.activate ‘/activate/:activation_code’, :controller => ‘users’, :action => ‘a
ctivate’, :activation_code => nil
map.signup ‘/signup’, :controller => ‘users’, :action => ‘new’
map.login ‘/login’, :controller => ‘sessions’, :action => ‘new’
map.logout ‘/logout’, :controller => ‘sessions’, :action => ‘destroy’———————————————————————-
exists app/models/
exists app/controllers/
exists app/controllers/
exists app/helpers/
create app/views/sessions
create app/views/user_mailer
exists app/controllers/
exists app/helpers/
create app/views/users
exists test/functional/
exists test/functional/
exists test/unit/
create app/models/user.rb
create app/models/user_mailer.rb
create app/models/user_observer.rb
create app/controllers/sessions_controller.rb
create app/controllers/users_controller.rb
create lib/authenticated_system.rb
create lib/authenticated_test_helper.rb
create test/functional/sessions_controller_test.rb
create test/functional/users_controller_test.rb
create test/unit/user_test.rb
create test/unit/user_mailer_test.rb
create test/fixtures/users.yml
create app/helpers/sessions_helper.rb
create app/helpers/users_helper.rb
create app/views/sessions/new.html.erb
create app/views/users/new.html.erb
create app/views/user_mailer/activation.html.erb
create app/views/user_mailer/signup_notification.html.erb
create db/migrate
create db/migrate/20080825221326_create_users.rb
route map.resource :session
route map.resources :users
■5. acts_as_state_machine プラグインもインストール
activationとかstatefulとかに必要らしい。
$ ./script/plugin install http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk/
C:Documents and SettingsMiyaiMy DocumentsNetBeansProjectsrubyweblog>ruby sc
ript/plugin install http://elitists.textdriven.com/svn/plugins/acts_as_state_mac
hine/trunk/
+ ./CHANGELOG
+ ./MIT-LICENSE
+ ./README
+ ./Rakefile
+ ./TODO
+ ./init.rb
+ ./lib/acts_as_state_machine.rb
+ ./test/acts_as_state_machine_test.rb
+ ./test/database.yml
+ ./test/fixtures/conversation.rb
+ ./test/fixtures/conversations.yml
+ ./test/fixtures/person.rb
+ ./test/schema.rb
+ ./test/test_helper.rbC:Documents and SettingsMiyaiMy DocumentsNetBeansProjectsrubyweblog>
■6.migrate!(マイグレーション用ファイルは、上記のジェネレート時に設定済み)
netbeans上で、DBを最新化
(in C:/Documents and Settings/Miyai/My Documents/NetBeansProjects/rubyweblog)
== 20080825221326 CreateUsers: migrating ======================================
– create_table(“users”, {:force=>true})
-> 0.0160s
== 20080825221326 CreateUsers: migrated (0.0160s) =============================
ここでhp参照
http://localhost:3000/user/new
でルーティングエラー
よくわからんかったので、認証テスト用の簡易ブログを作成する事にする。
■この認証利用のためのscaffoldを準備
Post title:string content:text
migrateする
(in C:/Documents and Settings/Miyai/My Documents/NetBeansProjects/rubyweblog)
== 20080825222339 CreatePosts: migrating ======================================
– create_table(:posts)
-> 0.0470s
== 20080825222339 CreatePosts: migrated (0.0470s) =============================
app/controllers/sessions_controller.rb
を開いて、四行目の
include AuthenticatedSystem
をカットして保存。
同じフォルダ内にある
application.rb
を開いて
class ApplicationController < ActionController::Base
の内側にカットしたソースをペースト。
これでユーザ認証の機能が実装された。Railsではアクションごとにユーザ認証をかけるために「フィルタ」という仕組みを利用する。ユーザ認証はアクションを実行する前にフィルタを通す必要があるので「Before」フィルタを使う。
ユーザ認証をかけたい部分の***_controller.rb(この場合はapp/controllers/posts_controller.rb)というファイルを開き、二行目にそのフィルタを追記する。
before_filter :login_required, :except => [:index, :show]
※:exceptはオプションで、ここで指定されているindex(一覧ページ)は認証なしで閲覧可能になっている。
ここで、さっきのURLに間違いを発見
http://localhost:3000/users/new
で、いけた!
id,email,passwordを入力
http://localhost:3000/
に戻ってくる。登録できているのか?、ステータスは?
mysqlで確認
C:Documents and SettingsMiyaiMy DocumentsNetBeansProjectsrubyweblog>mysql -
u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql> use database rubyweblog_development;
ERROR 1049 (42000): Unknown database ‘database’
mysql> use rubyweblog_development;
Database changed
mysql> show tables;
+———————————-+
| Tables_in_rubyweblog_development |
+———————————-+
| posts |
| schema_migrations |
| users |
+———————————-+
3 rows in set (0.00 sec)mysql> select * from users
-> ;
+—-+——–+—————–+——————————————+—-
————————————–+———————+——————-
–+—————-+—————————+——————————–
———-+————–+———+————+
| id | login | email | crypted_password | sal
t | created_at | updated_at
| remember_token | remember_token_expires_at | activation_code
| activated_at | state | deleted_at |
+—-+——–+—————–+——————————————+—-
————————————–+———————+——————-
–+—————-+—————————+——————————–
———-+————–+———+————+
| 1 | tmiyai | takuya@miyai.jp | fc9f16b6bc098badff9347916241545135da9324 | e98
8284bddeb979e4cf87e54a669c0932454fcd2 | 2008-08-25 22:34:10 | 2008-08-25 22:34:1
0 | NULL | NULL | a9c735a91ac344ef39fc849e0e3c359
71854c94f | NULL | pending | NULL |
+—-+——–+—————–+——————————————+—-
————————————–+———————+——————-
–+—————-+—————————+——————————–
———-+————–+———+————+
1 row in set (0.00 sec)mysql> select login, state from users;
+——–+———+
| login | state |
+——–+———+
| tmiyai | pending |
+——–+———+
1 row in set (0.00 sec)mysql>
以下を、routes.rbに追加
activateするために必要らしい。
map.connect “activate/:activation_code”, :controller => “users”, :action => “activate”
この辺でよくわからなくなってくる。
てらじろぐ | restful_authentication でメール認証するぞ
restful_authenticationの設定 – べるべる研究日誌
この辺を見て、再トライだな。。。
Tags: Ruby on Rails
Posted in Programing | No Comments »
日曜日, 8月 24th, 2008
Lenovo note NetBeans開発環境
ruby インストール
・One-Click Ruby
ruby186-26.exe
システム環境変数の”path”に追加
;C:\ruby\bin
・MySQL
mysql-essential-5.0.51b-win32.msi
default character を utf8 に変更
Include Bin Directory in Windows PATHにチェックオン
・Rails
gemsでインストール
> gem install rails
c:\ruby>gem install rails
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency rake? [Yn] Y
Install required dependency activesupport? [Yn] Y
Install required dependency activerecord? [Yn] Y
Install required dependency actionpack? [Yn] Y
Install required dependency actionmailer? [Yn] Y
Install required dependency activeresource? [Yn] Y
Successfully installed rails-2.1.0
Successfully installed rake-0.8.1
Successfully installed activesupport-2.1.0
Successfully installed activerecord-2.1.0
Successfully installed actionpack-2.1.0
Successfully installed actionmailer-2.1.0
Successfully installed activeresource-2.1.0
Installing ri documentation for rake-0.8.1…
Installing ri documentation for activesupport-2.1.0…
Installing ri documentation for activerecord-2.1.0…
Installing ri documentation for actionpack-2.1.0…
Installing ri documentation for actionmailer-2.1.0…
Installing ri documentation for activeresource-2.1.0…
Installing RDoc documentation for rake-0.8.1…
Installing RDoc documentation for activesupport-2.1.0…
Installing RDoc documentation for activerecord-2.1.0…
Installing RDoc documentation for actionpack-2.1.0…
Installing RDoc documentation for actionmailer-2.1.0…
Installing RDoc documentation for activeresource-2.1.0…
c:\ruby>gem install rails
Successfully installed rails-2.1.0
インストール許可を省略する際には”-y”オプション
> gem install rails -y
1.2系をインストールする場合は以下参照
> gem install rails –version=”1.2.6″ -y
C:\Documents and Settings\Miyai>mysql –version
mysql Ver 14.12 Distrib 5.0.51b, for Win32 (ia32)
C:\Documents and Settings\Miyai>rails -v
Rails 2.1.0
C:\Documents and Settings\Miyai>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
・NetBeansインストール
JDKが必要
http://java.sun.com/j2se/1.5.0/ja/download.html
netbeans-6.1-ml-ruby-windows.exe
※mlはマルチランゲージの事。日本語版を含みます。
チュートリアル
http://www.netbeans.org/kb/60/ruby/rapid-ruby-weblog_ja.html
■なぜか、データベースが作成できない。
C:\Documents and Settings\Miyai>mysqladmin -u root -p create rubyweblog_developm
ent
Enter password: ********
mysqladmin: CREATE DATABASE failed; error: ‘Can’t create database ‘rubyweblog_de
velopment’; database exists’
C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> quit;
Bye
C:\Documents and Settings\Miyai>mysqladmin -u root -p create rubyweblog_developm
ent
Enter password: ********
mysqladmin: CREATE DATABASE failed; error: ‘Can’t create database ‘rubyweblog_de
velopment’; database exists’
C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> quit;
Bye
C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> create database rubyweblog_development;
ERROR 1007 (HY000): Can’t create database ‘rubyweblog_development’; database exi
sts
■どうやら同名のデータベースがある模様。(アンインストール失敗していた?)
mysql> show databases;
+————————+
| Database |
+————————+
| information_schema |
| depot_development |
| mysql |
| rubyweblog_development |
| test |
+————————+
5 rows in set (0.23 sec)
■不要なデータベースを削除
mysql> drop database depot_development;
Query OK, 2 rows affected (0.33 sec)
mysql> drop database rubyweblog_development;
Query OK, 0 rows affected (0.00 sec)
mysql> drop database test;
Query OK, 0 rows affected (0.02 sec)
mysql> quit;
Bye
■無事作成できた。
C:\Documents and Settings\Miyai>mysqladmin -u root -p create rubyweblog_development
Enter password: ********
C:\Documents and Settings\Miyai>
■しかし、チュートリアルどおり進まない。
rails1.2系と、rails2.0系の違い
教えて! Watch Ruby on Rails について
http://oshiete1.watch.impress.co.jp/qa4070054.html
始める。 ・テンプレートファイルの名称がXXX.rhtmlからXXX.html.erbに変更 ってとこです。
http://yamamoto.xrea.jp/2008/02/ruby-on-rails-20scaffold.php
——————————————————-
1.railsコマンドでひな形を作成
※rails2.0ではデフォルトのDBがSQLite3なので、mysqlで使う場合は”-d mysql”オプションが必要かもです。
2.database.ymlを修正
3.おもむろにscaffold実行
ruby script/generate scaffold pepole name:string age:integer
4.dbにデータベースを作る
5.mygrateする
rake db:migrate
6.serverをスタートする
——————————————————-
↓
NetBeansのチュートリアル手順を改造するとこんな感じか
——————————————————-
1.db内にデータベース作成する。
2.初期ウィザードで、Mysql指定(これでdatabase.ymlも自動生成)
3.scaffold生成
4.mygrationファイル修正
5.mygrate
6.実行!
——————————————————-
明日やってみる。
Tags: Mysql, Netbeans, Ruby on Rails
Posted in Programing | No Comments »
金曜日, 8月 22nd, 2008
RaPT: Railsプラグイン管理ツール – Hello, world! – s21g
Tags: Ruby on Rails
Posted in Programing | No Comments »
金曜日, 8月 22nd, 2008
昨日の手順に従って実施。
1.DBの作成
C:\Documents and Settings\Miyai>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> create database rubyweblog_development;
Query OK, 1 row affected (0.00 sec)mysql> show databases;
+————————+
| Database |
+————————+
| information_schema |
| mysql |
| rubyweblog_development |
+————————+
3 rows in set (0.00 sec)mysql>
2.railsプロジェクトの作成
rubyweblog作った!
3. restful_authentication プラグインのインストール
$ ./script/plugin discover
C:\Documents and Settings\Miyai\My Documents\NetBeansProjects\rubyweblog>ruby script/plugin discover
Add http://www.agilewebdevelopment.com/plugins/? [Y/n] Y
Add svn://rubyforge.org/var/svn/expressica/plugins/? [Y/n] Y
Add http://soen.ca/svn/projects/rails/plugins/? [Y/n] Y
Add http://technoweenie.stikipad.com/plugins/? [Y/n] Y
Add http://svn.techno-weenie.net/projects/plugins/? [Y/n] Y
Add http://svn.recentrambles.com/plugins/? [Y/n] Y
Add http://opensvn.csie.org/rails_file_column/plugins/? [Y/n] Y
Add http://svn.protocool.com/public/plugins/? [Y/n] Y
Add http://tools.assembla.com/svn/breakout/breakout/vendor/plugins/? [Y/n] Y
Add http://svn.pragprog.com/Public/plugins/? [Y/n] Y
Add http://source.collectiveidea.com/public/rails/plugins/? [Y/n] Y
Add https://secure.near-time.com/svn/plugins/? [Y/n] Y
Add http://svn.inlet-media.de/svn/rails_extensions/plugins/? [Y/n] Y
Add http://svn.viney.net.nz/things/rails/plugins/? [Y/n] y
Add http://svn.hasmanythrough.com/public/plugins/? [Y/n] y
Add http://svn.shiftnetwork.com/plugins/? [Y/n] y
Add svn://caboo.se/plugins/? [Y/n] y
Add http://svn.6brand.com/projects/plugins/? [Y/n] y
Add http://shanesbrain.net/svn/rails/plugins/? [Y/n] y
Add svn://errtheblog.com/svn/plugins/? [Y/n] y
Add http://svn.nkryptic.com/plugins/? [Y/n] y
Add http://svn.thoughtbot.com/plugins/? [Y/n] y
Add http://svn.webwideconsulting.com/plugins/? [Y/n] y
Add http://invisible.ch/svn/projects/plugins/? [Y/n] y
Add svn://rubyforge.org/var/svn/enum-column/plugins/? [Y/n] y
Add http://hivelogic.com/plugins/? [Y/n] y
Add http://mattmccray.com/svn/rails/plugins/? [Y/n] y
Add svn://rubyforge.org/var/svn/cartographer/plugins/? [Y/n] y
Add http://www.svn.recentrambles.com/plugins/? [Y/n] y
Add http://tanjero.com/svn/plugins/? [Y/n] y
Add http://filetofsole.org/svn/public/projects/rails/plugins/? [Y/n] y
Add http://topfunky.net/svn/plugins/? [Y/n] y
Add svn://rubyforge.org/var/svn/agtools/plugins/? [Y/n] y
Add http://svn.aviditybytes.com/rails/plugins/? [Y/n] y
Add http://beautifulpixel.textdriven.com/svn/plugins/? [Y/n] y
Add http://mabs29.googlecode.com/svn/trunk/plugins/? [Y/n] y
Add http://www.codyfauser.com/svn/projects/plugins/? [Y/n] y
Add http://craz8.com/svn/trunk/plugins/? [Y/n] y
Add http://sean.treadway.info/svn/plugins/? [Y/n] y
Add http://svn.thebootstrapnation.com/public/plugins/? [Y/n] y
Add http://www.mattmccray.com/svn/rails/plugins/? [Y/n] y
Add svn://rubyforge.org//var/svn/validaterequest/plugins/? [Y/n] y
Add http://sprocket.slackworks.com/svn/rails/plugins/? [Y/n] y
Add http://svn.simpltry.com/plugins/? [Y/n] y
Add http://svn.elctech.com/svn/public/plugins/? [Y/n] y
Add http://xmlblog.stikipad.com/plugins/? [Y/n] y
Add http://www.xml-blog.com/svn/plugins/? [Y/n] y
Add http://svn.toolbocks.com/plugins/? [Y/n] y
Add http://thar.be/svn/projects/plugins/? [Y/n] y
Add http://code.teytek.com/rails/plugins/? [Y/n] y
Add http://www.infused.org/svn/plugins/? [Y/n] y
Add svn://rubyforge.org/var/svn/apptrain/trunk/vendor/plugins/? [Y/n] y
Add http://s3cachestore.googlecode.com/svn/trunk/plugins/? [Y/n] y
Add http://sbecker.net/shared/plugins/? [Y/n] y
Add http://opensvn.csie.org/macaque/plugins/? [Y/n] y
Add http://svn.designbyfront.com/rails/plugins/? [Y/n] y
Add http://svn.rails-engines.org/plugins/? [Y/n] y
Add http://john.guen.in/svn/plugins/? [Y/n] y
Add http://www.redhillonrails.org/svn/trunk/vendor/plugins/? [Y/n] y
Add svn://rubyforge.org/var/svn/actsdisjoint/plugins/? [Y/n] y
Add http://ajaxmessaging.googlecode.com/svn/trunk/plugins/? [Y/n] y
Add http://mod-i18n.googlecode.com/svn/trunk/plugins/? [Y/n] y
Add svn://majakari.net/public/rails/plugins/? [Y/n] y
Add http://svn.devjavu.com/malaysia-rb/plugins/? [Y/n] y
Add http://svn.railslodge.com/svn/plugins/? [Y/n] y
Add http://flouzometer.rubyforge.org/svn/trunk/plugins/? [Y/n] y
Add svn://svn.spattendesign.com/svn/plugins/? [Y/n] y
Add http://rails.sanityinc.com/plugins/? [Y/n] y
Add http://svn.savvica.com/public/plugins/? [Y/n] y
Add https://svn01.allmyfunds.com.au/svn/public/plugins/? [Y/n] y
Add http://svn.megablaix.com/plugins/? [Y/n] y
Add http://to-json-options.rubyforge.org/svn/trunk/plugins/? [Y/n] y
Add http://rails-multifielddate-plugin.googlecode.com/svn/plugins/? [Y/n] y
Add http://flexible-rails.googlecode.com/svn/trunk/plugins/? [Y/n] y
Add http://sql-helper.rubyforge.org/svn/trunk/plugins/? [Y/n] y
Add http://winnscriptatype.rubyforge.org/svn/plugins/? [Y/n] y
Add svn://furtherin.net/rails/plugins/? [Y/n] y
Add http://dectxn.rubyforge.org/svn/tags/CURRENT/plugins/? [Y/n] y
$ ./script/plugin install restful_authentication
C:\Documents and Settings\Miyai\My Documents\NetBeansProjects\rubyweblog>ruby script/plugin install restful_authentication
+ ./README
+ ./Rakefile
+ ./generators/authenticated/USAGE
+ ./generators/authenticated/authenticated_generator.rb
+ ./generators/authenticated/templates/activation.html.erb
+ ./generators/authenticated/templates/authenticated_system.rb
+ ./generators/authenticated/templates/authenticated_test_helper.rb
+ ./generators/authenticated/templates/controller.rb
+ ./generators/authenticated/templates/fixtures.yml
+ ./generators/authenticated/templates/functional_spec.rb
+ ./generators/authenticated/templates/functional_test.rb
+ ./generators/authenticated/templates/helper.rb
+ ./generators/authenticated/templates/login.html.erb
+ ./generators/authenticated/templates/mailer.rb
+ ./generators/authenticated/templates/mailer_test.rb
+ ./generators/authenticated/templates/migration.rb
+ ./generators/authenticated/templates/model.rb
+ ./generators/authenticated/templates/model_controller.rb
+ ./generators/authenticated/templates/model_functional_spec.rb
+ ./generators/authenticated/templates/model_functional_test.rb
+ ./generators/authenticated/templates/model_helper.rb
+ ./generators/authenticated/templates/observer.rb
+ ./generators/authenticated/templates/signup.html.erb
+ ./generators/authenticated/templates/signup_notification.html.erb
+ ./generators/authenticated/templates/unit_spec.rb
+ ./generators/authenticated/templates/unit_test.rb
+ ./install.rb
+ ./lib/restful_authentication/rails_commands.rb
Restful Authentication Generator
====This is a basic restful authentication generator for rails, taken
from acts as authenticated. Currently it requires Rails 1.2.6 or above.To use:
./script/generate authenticated user sessions \
–include-activation \
–statefulThe first parameter specifies the model that gets created in signup
(typically a user or account model). A model with migration is
created, as well as a basic controller with the create method.The second parameter specifies the sessions controller name. This is
the controller that handles the actual login/logout function on the
site.The third parameter (–include-activation) generates the code for a
ActionMailer and its respective Activation Code through email.The fourth (–stateful) builds in support for acts_as_state_machine
and generates activation code. This was taken from:http://www.vaporbase.com/postings/stateful_authentication
You can pass –skip-migration to skip the user migration.
If you’re using acts_as_state_machine, define your users resource like this:
map.resources :users, :member => { :suspend => :put,
:unsuspend => :put,
:purge => :delete }Also, add an observer to config/environment.rb if you chose the
–include-activation optionconfig.active_record.observers = :user_observer # or whatever you
# named your model
Security Alert
====I introduced a change to the model controller that’s been tripping
folks up on Rails 2.0. The change was added as a suggestion to help
combat session fixation attacks. However, this resets the Form
Authentication token used by Request Forgery Protection. I’ve left
it out now, since Rails 1.2.6 and Rails 2.0 will both stop session
fixation attacks anyway.
■おまけ
> ruby script/plugin discover
は、リポジトリの追加
Rails Wiki – プラグイン
Plugins in Ruby on Rails
今日はここまで
Tags: Mysql, Ruby on Rails
Posted in Programing | No Comments »