摘要: ActionDispatch::Flash < Objec pass temporary primitive-types (String, Array, Hash) between actions. Anything you place in the flash will be exposed to 阅读全文
posted @ 2018-03-30 09:30 Mr-chen 阅读(211) 评论(0) 推荐(0)
摘要: params的理解和作用: http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-require Allows you to choose which attributes should be whi 阅读全文
posted @ 2018-03-29 10:56 Mr-chen 阅读(172) 评论(0) 推荐(0)
摘要: 第2章 Instant Gratification 复习 和 练习第一章,新建rails web页面。 重点: 页面生成的工作。(重点): 第3章 The Architecure of Rails Applications mvc架构创建Web应用。 Rails Model Support : Ob 阅读全文
posted @ 2018-03-23 10:28 Mr-chen 阅读(129) 评论(0) 推荐(0)
摘要: 闰年程序 require_relative './leap_year' describe "Leap Year" do it "2016 is leap year" do result = is_leap_year?(2016) # 把 2016 传进去 expect(result).to eq(t 阅读全文
posted @ 2018-03-22 19:59 Mr-chen 阅读(140) 评论(0) 推荐(0)
摘要: 编码规则 https://github.com/thoughtbot/guides/tree/master/style/ruby *Use a trailing comma after each item in a multi-line list, including the last item. 阅读全文
posted @ 2018-03-22 10:37 Mr-chen 阅读(185) 评论(0) 推荐(0)
摘要: Find The Find module supports the top-down traversal of a set of file paths.(一系列文件的路径的遍历) find(*paths, ignore_error: true) prune() require 'find' IGNO 阅读全文
posted @ 2018-03-20 10:49 Mr-chen 阅读(150) 评论(0) 推荐(0)
摘要: kernel#require_relative Ruby tries to load the library named string relative to the requiring file's path. 就是说当前运行文件的目录下面找这个要加载的文件。 如:/Users/个人/Ruby元编 阅读全文
posted @ 2018-03-19 22:16 Mr-chen 阅读(206) 评论(0) 推荐(0)
摘要: Spell,也称pattern,idiom # Around Alias:从一个重新定义的方法中调用原始的,被重命名的版本。 # old_reverse是未改变的原始方法,reverse/new_reverse是改变的方法。 class String def new_reverse "x:#{old 阅读全文
posted @ 2018-03-18 18:00 Mr-chen 阅读(231) 评论(0) 推荐(0)
摘要: 关于namespace,双冒号::的用法。 防止引用多个模块在一个文件/类中,有重名的对象。::可以调用类的类方法,和常量。 class Foo BAR = "hello" def self.hello puts "world" end end p Foo::BAR ✅ Foo::hello ✅ 根 阅读全文
posted @ 2018-03-18 09:33 Mr-chen 阅读(190) 评论(0) 推荐(0)
摘要: The boss's mission: 写一个类宏,功能与attr_accessor类似,但会创建经过校验的属性,名字attr_checked。 需求: A Development Plan: 开发计划: 第一步 创建2个拟态方法,读/写 方法。在写方法加入校验属性值是否nil/false. req 阅读全文
posted @ 2018-03-16 17:20 Mr-chen 阅读(125) 评论(0) 推荐(0)