railscast cast1-70的说明 也可以说是个人记录

1 session和变量运用?
2-3 models动态指令
4 转移到models指令
5 with_scope 运用
6 |p| p.name 可以转换成&:name
7 layouts 模板全部介绍(他说的=。=)
8 内容显示 yield css等
9 保护password不被记录
10-12 测试说明
13 session安全保存方式
14 console演示model指令
15 model conditions用法
17 联合
18 flash 显示错误、提示等
19-21 管理员 验证之类 以及简单登陆制作
22-23 联合INCLUDE减少读取时间(加数据项等)
24 irb 错误堆栈查找
25 SQL注入conditions=> 用['?','%'+params[:xx]+'%']
26 默认提交跨表传输   model 只保护 attr_protected :admin  只允许attr_accessable :name
27 跨站攻击 h(XX) 避免
28 数组(1..2).to_a  a.in_groups_of(4)4个一组 用于多列显示 a.in_groups_of(4,false)消除nil 换0

则用0填
29 依旧分组 按时间段来 @t_months=@t.group_by{|t| t.due_at.beginning_of_month}
   VIEW里 <% @t_months.each do |month,tasks| %>      或者 .keys.sort.each do |month|
  <h2><%= month.strftime('%B') %></h2>
  <% for task in tasks %>        @t_months[month]
   <%= task.name %>
  <% end %>
30 标题头。。view helper几个方式
31 时间格式 to_s(:long) (:short) (:db)  strftime()格式可用ri strftime查看
   格式类型可以在environment.rb里面定义
   Time::DATE_FORMATS[:due_time]=strftime("due at %B %d on %I:%M %p")
32 ruby chronic根据字符串转成数据库日期
   rescue ArgumentError相当于try  (begin rescue end)
   errors.add(:due_at,"is invalid") if @due_at_invalid 错误追加
33 自己做插件
validates_presence_of :name 必填
   插件 stringify_time :due_at
   script/generate plugin stringify_time
  -init.rb
 require "stringify_time"
 
 class ActiveRecord::Base
   extend StringifyTime
 end
  -stringify_time.rb
 module StringifyTime
  def stringify_time(*names)
   names.each do |name|
     define_method "#{name}_string" do
  read_attribute(name).to_s(:db)
     end

     define_method "#{name}_string=" do |time_str|
       begin
        write_attribute(name,Time.parse(time_str)
              rescue ArgumentError
        instance_variable_set("@#{name}_invalid",true)
       end
     end
#+++ 
     define_method "#{name}_invalid" do
  instance_variable_get("@#{name}_invalid")
     end
   end
  end
 end
#从下面语句改成以上插件
#  def due_at_string
#    due_at.to_s(:db)
#  end
#  def due_at_string=(due_at_str)
###    self.due_at =Time.parse(due_at_str)
#  rescue ArgumentError
#    @due_at_invalid = true
#  end
# end
if due_at_invalid?

34 routes表编写 xx_path 相对路径 xx_url 完整路径 带参数的路径设置
35 rest 多余项目 routes表填加 map.resources :task,:collection => {:completed => :get}
   :member =>{:complete => :put}
   @task.update_attribute :completed_at,Time.now 直接更新完成某一项
 
36 subversion 版本控制
   rails blob
   cd blob
   mv config/database.yml config/database_example.yml复制?
   rm -r log/*
   rm -r tmp/*
   cd ..
   mv blob trunk
   mkdir tags
   mkdir branches
   svn import. svn://localhost/blob -m "initial import" --username rbates
   cd..
   svn co svn://localhost/blob/trunk blob
   cd blob  
   cp config/database_example.yml config/database.yml
   svn status
   svn propset svn:lgnore database.yml config/
   svn propset svn:lgnore "*" log//
   svn propset svn:lgnore "*" tmp//
   svn propset svn:lgnore "*" tmp/
   svn status
   svn commit -m "lgnoring files"
   
   script/generate model item -c
   svn status
   svn add db/schema.rb 填加过去了
   textmate 反点项目commit过去。。 还能写注释
   那其他的怎么办=。= 逼我用netbean?

  -x 直接写SVN?

37 简单搜索
38 预览
39 自定义错误框
40 应该是讲admin_area

41 models conditional 各种验证 attr_accessor :xx 允许xx传入
42 with_options 选项 像each do |what| 还有根据一个controller 多次指定那样
   with_options :if =>:should_validate_password do |what|
   what.validates_presence_of :password # == validates_presence_of :password :if

=>:should_validate_password

43 ajax rjs
flash[:notice]
flash.discard 免得rjs传输 不清除

44 js ajax debug
45 rjs一些prototype特效
46 route 显示 说明参数 包括查找相似头 然后跳转
47 many to many 通过has_many thought
48 console 指令提示
49 怎样查API
50 提交RAILS项目?
51 will_paginate(翻页插件介绍)
52 checkboxes更新项目 没什么好说的
53 错误跳转
54 debug rails。。。
55 干净的view制作方法
56 LOG显示
57 选择或者创建关联
58 用模板构件普通页
59 创建数据库项  防过期处理
60 不用fixtures的测试
61 发送邮件
62 hacking activerecord 验证还是测试。。 搞不清楚
63 url美化 def to_param "#{id}-#{permalink}" find(params[:id].to_i)
64 自定义helper
65 stopping spam 不懂
66 自定义rake 任务
67 用户管理插件
68 用户邮件认证?
69 markaby in helper? 感觉是个类似haml插件 没haml好
70 依旧route接收params说明 自定义routes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值