云端开发环境,Cloud9(https://ide.c9.io/)。这个开发环境预先安装好了Rails开发所需要的大多数软件,包括Ruby、RubyGems和Git,需要自己安装Rails。
1、安装rails:$gem install rails -v 4.1.6
2、创建项目:$rails _4.1.6_ new hello_app
hello_app的目录结构如下所示:
各个目录的内容及含义如下:
3、修改Gemfile,然后执行如下语句:
$bundle install
Gemfile的文件的内容如下:
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3' # Use SCSS for stylesheets
# gem 'sass-rails', '~> 4.0.3'
gem 'sass-rails', '5.0.0.beta1'
# Use Uglifier as compressor for JavaScript assets
# gem 'uglifier', '>= 1.3.0'
gem 'uglifier', '2.5.3'
# Use CoffeeScript for .js.coffee assets and views
# gem 'coffee-rails', '~> 4.0.0'
gem 'coffee-rails', '4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library
gem 'jquery-rails'
# gem 'jquery-rails', '4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'
gem 'turbolinks', '2.3.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.0'
gem 'jbuilder', '2.2.3'
# bundle exec rake doc:rails generates the API under doc/api.
# gem 'sdoc', '~> 0.4.0', group: :doc
gem 'sdoc', '0.4.0', group: :doc # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
#gem 'spring', group: :development # Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server
# gem 'unicorn' # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development # Use debugger
# gem 'debugger', group: [:development, :test]
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
4、运行rails server:
$rails server -b $IP -p $PORT