ROR version 1.1.2  学习笔记(本地环境已经达到了2.1)

1. 自动的数据库加载工具
    应该用好rake工具,它就像make工具给开发人员提供了一键式服务模式.以添加数据库表为例:
    rake db:migrate
    会自动执行db/migrate/*.rb所有文件.
    当然migrate文件也许要按照一定格式书写.

2. 通过javascript达到url链接的post提交方式.
    关于为什么需要使用post提交方式,在滑板书上有详细介绍.在这里不再赘述.
    在书写的时候非常简单
        <%= link_to 'Destroy', { :action => 'destroy', :id => product },:confirm =>'Are you sure?',:post => true %>
        不知道我这里是否是2.1版本的原因,这种配置无法达到post的效果,需要换一种书写方式.
        <%= link_to 'Destroy', { :action => 'destroy', :id => product },:confirm => 'Are you sure?',:method => :post  %>
        这是2.1 rdoc中的讲解:
            :method => symbol of HTTP verb - This modifier will dynamically create an HTML form and immediately submit the form for processing using the HTTP verb specified. Useful for having links perform a POST operation in dangerous actions like deleting a record (which search bots can follow while spidering  your site). Supported verbs are :post, :delete and :put. Note that if the user has JavaScript disabled, the request will fall back to using GET. If you are  relying on the POST behavior, you should check for it in your controller‘s action by using the request object‘s methods for post?, delete? or put?.

3. 将session放在数据库中
    rake db:sessions:create
        class CreateSessions < ActiveRecord::Migration
          def self.up
            create_table :sessions do |t|
              t.string :session_id, :null => false
              t.text :data
              t.timestamps
            end

            add_index :sessions, :session_id
            add_index :sessions, :updated_at
          end

          def self.down
            drop_table :sessions
          end
        end
    将environment.rb文件中的config.action_controller.session_store = :active_record_store注释去掉即可

4. rjs模板文件的学习

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值