Ruby on Rails hands-on notes (installation using the entire process) _ruby topics

Source: Internet
Author: User
Tags ruby on rails

There is a chance to try rails again, only the original contact is 2, now has become 4, it seems that the installation is now faster than the original.

Rails 4 Installation

Aimed at installing the RVM

Copy Code code as follows:
Gem Install Rails

If not, it should be:
Copy Code code as follows:
sudo gem install rails

Install RVM can use a sentence
Copy Code code as follows:
Curl-l Https://get.rvm.io | Bash-s Stable


View Rails Version

Copy Code code as follows:
Rails-v
Rails 4.0.3

It seems that this is the latest version of the current

Ruby version

Copy Code code as follows:
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+ 'll be supported until Rails 5.

Officially recommended with 2.1.0. That's the latest version.

Install SQLite

It seems that this is the database requirements for lightweight web sites such as Django and rails.

If the Mac OS

Copy Code code as follows:
Brew Install Sqlite3

Other things can be seen installed, such as openSUSE
Copy Code code as follows:
sudo zypper install Sqlite3


Rails 4 Hello,world

Can be generated directly with rails

Copy Code code as follows:
$rails New Hello

And then there's the
Copy Code code as follows:

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

The package dependencies are then installed
Copy Code code as follows:

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 the where a bundled gem is installed.

Run Rails

Copy Code code as follows:
$rails Server

Such words open http://localhost:3000 can be seen, rails welcome interface welcome aboard, a bit similar to the DJANGO-CMS pony Brother ~ ~

Create Controller

As the official guide says http://guides.rubyonrails.org/getting_started.html

To execute a command:

Copy Code code as follows:
$rails Generate Controller Welcome index

The following files are created:
Copy Code code as follows:

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

Add a default page to CONFIG/ROUTES.RB

Copy Code code as follows:
Root ' Welcome#index '

Run again
Copy Code code as follows:
Rails Server

will appear

Copy Code code as follows:
Welcome#index

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


Everything came quickly, very suddenly.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.