本节主要是安装 restful_authentication
ruby script\plugin install -r 3702 http://svn.techno-weenie.net/projects/plugins/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\generate authenticated user sessions
将创建模型类、数据库迁徙任务、html视图等文件。
rake db:migate 执行数据库迁徙任务
书中进行简单的routing,并将若干种controller共同的代码移到application.rb文件中
restful_authenticated插件的功能与Agile Web Development with Rails书中讲述的方法基本一致。只是使用更方便了?
==========
Pomodo.mxml详解
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
backgroundGradientColors="[#ffffff, #c0c0c0]"
width="100%"
height="100%">
url="/hello/sayhello"
method="POST"/>
Flex应用的根元素一定应该是 mx:Application
The mx: part dentifies the XML namespace that the Application component is from.
We use vertical layout to make the components flow vertically.
Other choices are horizontal for horizontal flow) and absolute (where you specify the x,y of each toplevel ontainer).
The backgroundGradientColors specify the start and end of he gradient fill for the background
HTTPService 元素用来调用HelloController的sayhello方法,在默认情况下,Rails中URLs are mapped /controller_name/action_name. 控制器的名字首字母是大写的,并且假定有Controller,因此 /hello maps to HelloController,and sayhello maps to the sayhello action (which is a method); url="/hello/sayhello" maps to the sayhello method of the HelloController class.
We aren’t passing any parameters right now; you’ll do this soon when you try to log in.
The id of the HTTPService is helloSvc
在MXML中,控件的id属性是该控件的名字。如果我们不指定一个id,flex将随机生成一个id,这样的话,代码中就不能引用它了。
总体来讲,上面的代码还是很好懂的。