濮阳杆衣贸易有限公司

主頁 > 知識庫 > Ruby On Rails上手筆記(安裝使用全過程)

Ruby On Rails上手筆記(安裝使用全過程)

熱門標(biāo)簽:AI電銷機(jī)器人 線路 淮安自動外呼系統(tǒng)供應(yīng)商 外呼線路從哪里出來的 柯城手機(jī)地圖如何做地圖標(biāo)注 天津外呼系統(tǒng)怎么收費(fèi) 征服者企業(yè)地圖標(biāo)注 中牟外呼系統(tǒng)違法嗎 巫師3地圖標(biāo)注魔力之所 漯河電銷

有機(jī)會再試一試Rails了,只是原來接觸的是2,現(xiàn)在已然變成了4,似乎現(xiàn)在的安裝比原來會快些。。

Rails 4 安裝

針對于安裝了RVM

復(fù)制代碼 代碼如下:
gem install rails

沒有的話應(yīng)該這樣:
復(fù)制代碼 代碼如下:
sudo gem install rails

安裝RVM可以用句
復(fù)制代碼 代碼如下:
curl -L https://get.rvm.io | bash -s stable


查看rails版本

復(fù)制代碼 代碼如下:
rails -v
Rails 4.0.3

似乎這就是當(dāng)前的最新版本

Ruby版本

復(fù)制代碼 代碼如下:
We recommend Ruby 2.1.0 for use with Rails. We stopped supporting Ruby 1.8.x after Rails 3.2. Ruby 1.9.2+ will be supported until Rails 5.

官方推薦用2.1.0. 也就是最新版本

安裝SQLite

似乎這就是諸如Django、Rails這類對于輕量級網(wǎng)站的數(shù)據(jù)庫要求。

如果是mac os

復(fù)制代碼 代碼如下:
brew install sqlite3

其他可以看情況安裝,如openSUSE
復(fù)制代碼 代碼如下:
sudo zypper install sqlite3


Rails 4 Hello,World

可以直接用rails生成

復(fù)制代碼 代碼如下:
$rails new hello

于是就有了
復(fù)制代碼 代碼如下:

  create
  create  README.rdoc
  create  Rakefile
  create  config.ru
  create  .gitignore
  create  Gemfile
  create  app
  create  app/assets/javascripts/application.js
  create  app/assets/stylesheets/application.css
  create  app/controllers/application_controller.rb
  create  app/helpers/application_helper.rb
  create  app/views/layouts/application.html.erb
  create  app/assets/images/.keep
  create  app/mailers/.keep
  create  app/models/.keep
  create  app/controllers/concerns/.keep
  create  app/models/concerns/.keep
  create  bin
  create  bin/bundle
  create  bin/rails
  create  bin/rake
  create  config
  create  config/routes.rb
  create  config/application.rb
  create  config/environment.rb
  create  config/environments
  create  config/environments/development.rb
  create  config/environments/production.rb
  create  config/environments/test.rb
  create  config/initializers
  create  config/initializers/backtrace_silencers.rb
  create  config/initializers/filter_parameter_logging.rb
  create  config/initializers/inflections.rb
  create  config/initializers/mime_types.rb
  create  config/initializers/secret_token.rb
  create  config/initializers/session_store.rb
  create  config/initializers/wrap_parameters.rb
  create  config/locales
  create  config/locales/en.yml
  create  config/boot.rb
  create  config/database.yml
  create  db
  create  db/seeds.rb
  create  lib
  create  lib/tasks
  create  lib/tasks/.keep
  create  lib/assets
  create  lib/assets/.keep
  create  log
  create  log/.keep
  create  public
  create  public/404.html
  create  public/422.html
  create  public/500.html
  create  public/favicon.ico
  create  public/robots.txt
  create  test/fixtures
  create  test/fixtures/.keep
  create  test/controllers
  create  test/controllers/.keep
  create  test/mailers
  create  test/mailers/.keep
  create  test/models
  create  test/models/.keep
  create  test/helpers
  create  test/helpers/.keep
  create  test/integration
  create  test/integration/.keep
  create  test/test_helper.rb
  create  tmp/cache
  create  tmp/cache/assets
  create  vendor/assets/javascripts
  create  vendor/assets/javascripts/.keep
  create  vendor/assets/stylesheets
  create  vendor/assets/stylesheets/.keep
run  bundle install

接著會安裝包依賴
復(fù)制代碼 代碼如下:

  Fetching gem metadata from https://rubygems.org/..........
  Fetching additional metadata from https://rubygems.org/..
  Resolving dependencies...
  Using rake (10.3.1)
  Using i18n (0.6.9)
  Using minitest (4.7.5)
  Using multi_json (1.9.2)
  Using thread_safe (0.3.3)
  Using tzinfo (0.3.39)
  Using activesupport (4.0.3)
  Using builder (3.1.4)
  Using erubis (2.7.0)
  Using rack (1.5.2)
  Using rack-test (0.6.2)
  Using actionpack (4.0.3)
  Using mime-types (1.25.1)
  Using polyglot (0.3.4)
  Using treetop (1.4.15)
  Using mail (2.5.4)
  Using actionmailer (4.0.3)
  Using activemodel (4.0.3)
  Using activerecord-deprecated_finders (1.0.3)
  Using arel (4.0.2)
  Using activerecord (4.0.3)
  Using bundler (1.5.3)
  Using coffee-script-source (1.7.0)
  Using execjs (2.0.2)
  Using coffee-script (2.2.0)
  Using thor (0.19.1)
  Using railties (4.0.3)
  Using coffee-rails (4.0.1)
  Using hike (1.2.3)
  Using jbuilder (1.5.3)
  Using jquery-rails (3.1.0)
  Using json (1.8.1)
  Using tilt (1.4.1)
  Using sprockets (2.11.0)
  Using sprockets-rails (2.0.1)
  Using rails (4.0.3)
  Using rdoc (4.1.1)
  Using sass (3.2.19)
  Using sass-rails (4.0.3)
  Using sdoc (0.4.0)
  Using sqlite3 (1.3.9)
  Using turbolinks (2.2.2)
  Using uglifier (2.5.0)
  Your bundle is complete!
  Use `bundle show [gemname]` to see where a bundled gem is installed.

運(yùn)行Rails

復(fù)制代碼 代碼如下:
$rails server

這樣的話打開 http://localhost:3000 就可以看到,Rails的歡迎界面Welcome aboard,有點類似于Django-CMS的小馬哥~~

創(chuàng)建controller

如官方指南所說http://guides.rubyonrails.org/getting_started.html

執(zhí)行命令:

復(fù)制代碼 代碼如下:
$rails generate controller welcome index

就會創(chuàng)建下面這些文件:
復(fù)制代碼 代碼如下:

  create  app/controllers/welcome_controller.rb
   route  get "welcome/index"
  invoke  erb
  create    app/views/welcome
  create    app/views/welcome/index.html.erb
  invoke  test_unit
  create    test/controllers/welcome_controller_test.rb
  invoke  helper
  create    app/helpers/welcome_helper.rb
  invoke    test_unit
  create      test/helpers/welcome_helper_test.rb
  invoke  assets
  invoke    coffee
  create      app/assets/javascripts/welcome.js.coffee
  invoke    scss
  create      app/assets/stylesheets/welcome.css.scss

在config/routes.rb添加默認(rèn)頁面

復(fù)制代碼 代碼如下:
root 'welcome#index'

再運(yùn)行
復(fù)制代碼 代碼如下:
rails server

就會出現(xiàn)

復(fù)制代碼 代碼如下:
Welcome#index

Find me in app/views/welcome/index.html.erb


一切來得很快,很突然。

您可能感興趣的文章:
  • 快速安裝Ruby on Rails的簡明指南
  • win7安裝ruby on rails開發(fā)環(huán)境
  • 在 Ubuntu 12.04 Server 上安裝部署 Ruby on Rails 應(yīng)用
  • Windows下Ruby on Rails開發(fā)環(huán)境安裝配置圖文教程
  • CentOS7下搭建ruby on rails開發(fā)環(huán)境
  • Ruby on Rails下的圖像處理入門教程
  • 幾個加速Ruby on Rails的編程技巧
  • Ruby on rails安裝后去掉DL is deprecated,please use Fiddle警告信息的方法【測試可用】

標(biāo)簽:棗莊 內(nèi)江 南昌 西雙版納 克拉瑪依 大慶 甘孜 河池

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Ruby On Rails上手筆記(安裝使用全過程)》,本文關(guān)鍵詞  Ruby,Rails,上手,筆記,安裝,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Ruby On Rails上手筆記(安裝使用全過程)》相關(guān)的同類信息!
  • 本頁收集關(guān)于Ruby On Rails上手筆記(安裝使用全過程)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    泊头市| 浦江县| 大英县| 布尔津县| 彭水| 涪陵区| 龙口市| 昌江| 鄢陵县| 调兵山市| 金昌市| 信阳市| 南溪县| 柳林县| 昌都县| 天津市| 蓬莱市| 平果县| 西乌珠穆沁旗| 南投县| 宁城县| 宜阳县| 通州市| 安乡县| 灌阳县| 湖北省| 永修县| 齐齐哈尔市| 南京市| 杭锦后旗| 拜泉县| 宜兰市| 思茅市| 巴东县| 平定县| 十堰市| 铁岭市| 台江县| 丰镇市| 南陵县| 中山市|