Archive for 8月 22nd, 2008

22nd 8月
2008
written by tmiyai

昨日の手順に従って実施。

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 \
–stateful

The 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 option

config.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

今日はここまで