the rails philosophy includes two major guiding principles:

Don't repeat yourself: DRY is a principle of software development which states that "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system". By not writing the same information over and over again. our code is more maintainable,   more extensible, and less buggy.

Convention over Configuration: Rails has opinions about the best way to do many things in a web application, and defaults to this set of conventions, rather than require that you specify every minutiae through endless configuration files.



通过rubyonrails-guides,建立一个博客(全英文阅读)

命令:

rails new -h //看帮助help.

link_to  //method,Rail's built-in view helpers.

**

<%= link_to("My Blog", controller: "articles")%>  //当你链接到一个行为,而不在同一个controller的时候,你需要指定:controller option.

注释:⚠️ guide里有关于调用error_explanation的使用方法。如:pluralize(), @name,errors.full_messages.


❌:

1.undefined method `each' for nil:NilClass

分析:问题出在nilclass,each指向的class是空的。看一下传入的实例变量名字是不是写错了。


单词:

distinction:(区别)

trm/ (temporary:) 临时文件,缓存和pid

execute(kill sb/do sth/ferform an action)

malicious [mə'lɪʃəs]  (very unkind  and cruel, and deliberately behaving in a way that is likely to upset or hurt someone )

proceed:(verb, continue to do one thing)

process:(n,过程,进程,v,加工处理食品,数据等)

retrieve [rɪ'triːv]: to find sth and bring it back formal. to get back information that has been stored in the memory of a computer technical.检索。


new.html.erb 文件中。文件的扩展名很重要:第一个扩展名是模板格式,第二个扩展名是模板处理器。这个模板的格式只能是 html,模板处理器只能是 erbbuilder和 coffee 中的一个。:erb 是最常用的 HTML 模板处理器,:builder 是 XML 模板处理器,:coffee 模板处理器用 CoffeeScript 创建 JavaScript 模板。因为我们要创建 HTML 表单,所以应该使用能够在 HTML 中嵌入 Ruby 的 ERB 语言。

5.6 saving data in the controller

Class names in Ruby must begin with a capital letter.

render plain: params[:article].inspect 返回参数key的值并显示在屏幕上。

5.10 Adding Some Validation

redirect_to 和 render的一个区别

redirect_to :tell the browser to issue another request.(因此效能较低)

render: is done within the same request as the form submission(submit提交)

5.11 Updating Articles

@article.update(article_params) 更新全部,也可以更新部分内容,如下:

@article.update(text:"A new title")

formhelper activeview::helpers

http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for-label-Resource-oriented+style

t.integer :supplier_id 更明确地表明了外键的名称。在目前的 Rails 版本中,可以抽象实现的细节,使用 t.references :supplier 代替。

foreign_key 用于定义给关联的索引换一个名字

@comment = @article.comments.create  //create相当于new and save.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color: #3d3d3d; -webkit-text-stroke: #3d3d3d}
span.s1 {font-kerning: none}

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; color: #666666; -webkit-text-stroke: #666666}
span.s1 {font-kerning: none}

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color: #646464; -webkit-text-stroke: #646464}
span.s1 {font-kerning: none}

11月29日 The Rails philosophy 完成rails on guide 的第一章getting started with rails的更多相关文章

  1. 2016年11月29日 星期二 --出埃及记 Exodus 20:20

    2016年11月29日 星期二 --出埃及记 Exodus 20:20 Moses said to the people, "Do not be afraid. God has come t ...

  2. 20162311 解读同伴的收获&解决同伴的问题(11月29日,周三)

    20162311 解读同伴的收获&解决同伴的问题(11月29日,周三) 解读同伴的收获 我的同组同学是20162325学号金立清同学 同组同学的收获是:递归算法的非递归实现.分治法.动态规划法 ...

  3. 北京Uber优步司机奖励政策(11月23日~11月29日)

    用户组:人民优步"关羽组"(适用于11月23日-11月29日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最 ...

  4. 打开随身U盘_办公专用盘 2019年11月29日

    ;;; ; 打开随身U盘_办公专用盘 2019年11月29日 ; https://www.autoahk.com/?p=16553; https://www.cnblogs.com/delphixx/ ...

  5. 对OpenGL的GLFrame框架进行的扩展截至2014年11月29日

    框架源自<OpenGL游戏编程>,增加了此框架的部分功能.其中有些小错误,尤其是MD2模型的那章,给出的框架只支持载入一个BOSS,当再载入一个BOSS时,就会发现两个模型的帧速会乱套. ...

  6. Appium最新的服务器初始化参数(Capability)【截止11月29日,后续最新的可以看github】

    键 描述 值 automationName 自动化测试的引擎 Appium (默认)或者 Selendroid platformName 使用的手机操作系统 iOS, Android, 或者 Fire ...

  7. 西安OpenParty11月29日活动高清图文回顾——新增西安APEC蓝美图!

    本次活动由西安OpenParty负责线下活动组织运营,线上由InfoQ-QClub.OSChina协办. OSChina活动召集帖:运维为王——应用系统.DevOps与Docker(11月29日) I ...

  8. Git学习(二)(2015年11月18日)(2016年1月29日)

    2015年11月18日Git学习: .Shell 删除文件夹及其所有文件 rd/s/q 文件目录 ---------------当前为先创建本地Git库后与网上Git服务器关联------------ ...

  9. 本周MySQL官方verified/open的bug列表(11月8日至11月14日)

    本周MySQL verified的bug列表(11月8日至11月14日) 1. Bug #70859-DWITH_EXAMPLE_STORAGE_ENGINE=1 is ignored     URL ...

随机推荐

  1. 算法总结(转自CS-Notes)

    转载地址: 注意要点: 1.希尔排序:实际是将元素按步距h分为几组,每组元素没有关系,是组里每个元素跨步距h得到的一组元素是有序的,那么剩下的问题就是组内有序,再处理好组间边界即可.实际解决的方式是不 ...

  2. Golang模拟客户端POST表单功能文件上传

    客户端通过multipart.Write把文件的文本流写入一个缓存中,然后调用http的Post方法把缓存传到服务器. package main import ( "bytes" ...

  3. System.ServiceProcess与System.Configuration.Install命名空间的介绍

    System.ServiceProcess 命名空间提供用于实现.安装和控制 Windows 服务应用程序的类.服务是长期运行的可执行文件,其运行没有用户界面 System.ServiceProces ...

  4. Long类型转json时前端js丢失精度解决方案

    一.问题背景 Java后端开发过程中,尤其是id字段,因数值太大,通过json形式传输到前端后,在js解析时,会丢失精度. 如果对精度丢失没有什么概念,可以看一个知乎的帖子,来感受一下:https:/ ...

  5. <aop:aspect>与<aop:advisor>的区别

    在开发过程中,不少有Spring Aop的使用,在面向切面编程时,我们会使用< aop:aspect>:在进行事务管理时,我们会使用< aop:advisor>.那么,对于&l ...

  6. Codeforces 781B. Innokenty and a Football League

    题目链接:http://codeforces.com/contest/781/problem/B 去tmd 2-SAT 直接贪心就可以过去了,优先选择第二种情况. 然而....可以被叉掉(数据水了) ...

  7. 深入理解 java I/O

    Java 的 I/O 类库的基本架构 I/O 问题是任何编程语言都无法回避的问题,可以说 I/O 问题是整个人机交互的核心问题,因为 I/O 是机器获取和交换信息的主要渠道.在当今这个数据大爆炸时代, ...

  8. [原][unreal][UE][spark]分析unreal engine 虚幻引擎的粒子编辑器:Cascade

    参考:https://www.raywenderlich.com/270-unreal-engine-4-particle-systems-tutorial (使用了一个飞机射击游戏的粒子来展示,全英 ...

  9. [转][osg]关于PagedLOD 加载卸载机制

    你的PagedLOD 为什么没有卸载 转自:http://bbs.osgchina.org/forum.php?mod=viewthread&tid=7612&highlight=Pa ...

  10. eclipse中配置maven和创建第一个 Spring Boot Application

    关于Maven的下载.环境变量的配置自行百度,今天记录一下在Eclipse中配置Maven的操作: mvn -v 出现上图说明maven和jdk的要求都达到了(jdk要8.0及以上的版本) 然后在ec ...