摘要:
晚上实做第11章Ajax和jquery的练习。 11.2创建基于Ajax的购物车后,不能正确渲染partial,左边栏的局部更新。 后来突然想起来jquery在rails5.1去掉了,然后安装gem 'jquery-rails' ,bundle install,在application.js中加入r 阅读全文
摘要:
ActionDispatch::Flash < Objec pass temporary primitive-types (String, Array, Hash) between actions. Anything you place in the flash will be exposed to 阅读全文
摘要:
params的理解和作用: http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-require Allows you to choose which attributes should be whi 阅读全文
摘要:
第2章 Instant Gratification 复习 和 练习第一章,新建rails web页面。 重点: 页面生成的工作。(重点): 第3章 The Architecure of Rails Applications mvc架构创建Web应用。 Rails Model Support : Ob 阅读全文
摘要:
闰年程序 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 阅读全文
摘要:
编码规则 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. 阅读全文
摘要:
Find The Find module supports the top-down traversal of a set of file paths.(一系列文件的路径的遍历) find(*paths, ignore_error: true) prune() require 'find' IGNO 阅读全文
摘要:
kernel#require_relative Ruby tries to load the library named string relative to the requiring file's path. 就是说当前运行文件的目录下面找这个要加载的文件。 如:/Users/个人/Ruby元编 阅读全文
摘要:
Spell,也称pattern,idiom # Around Alias:从一个重新定义的方法中调用原始的,被重命名的版本。 # old_reverse是未改变的原始方法,reverse/new_reverse是改变的方法。 class String def new_reverse "x:#{old 阅读全文
摘要:
关于namespace,双冒号::的用法。 防止引用多个模块在一个文件/类中,有重名的对象。::可以调用类的类方法,和常量。 class Foo BAR = "hello" def self.hello puts "world" end end p Foo::BAR ✅ Foo::hello ✅ 根 阅读全文