天天看點

Ruby on Rails 基礎(1)前言概要

前言

Rails 是使用 Ruby 語言編寫的網頁程式開發架構

通過為開發者提供常用元件,來簡化網頁程式的開發

Tip: 類似于 python 的 Django ,perl 的 Dancer

Rails 架構有自己的指導思想:

  • 不重複造輪子(DRY)
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

這兩條編碼哲學可以算是曆代猴子們的智慧結晶,核心目标隻有一個,最大化的減少代碼規模,明确核心邏輯,而這樣的好處是多多的(編碼效率高,Debug也快)

DRY 自不用說,人生苦短,我們要站在巨人的肩膀上攀爬,不要把有限的生命浪費在人家已經反複踩過的坑裡

配置如果不在代碼内部消化,必然要在外面申明,而配置複雜到一定程度後,本身就已經成為了一門具備獨立文法的體系,邏輯不在代碼裡就在配置裡,邏輯是守恒的

這裡分享一下 Rails 的相關基礎,詳細可以參考 官方文檔 和 Ruby China 的 Rails 入門

Tip: 目前的最新版本為 Rails 5.0.0.beta3 釋出于 February 27, 2016 4:00 pm

概要

環境

[root@h202 ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m

[root@h202 ~]# uname -a 
Linux h202 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@h202 ~]#            

複制