Recent work requires learning a new language: Ruby. Uh, knowing that she exists because of an article circulating onlineHow to teach sister and girlfriend programming within two months, today finally to use, some small excitement ~ ~ and learned the door new language ~ ~Computer system is WIN8, in the Win8 under the VMware installed an Ubuntu 14.04 Kylin, yesterday afternoon first understand the win installation.
Win8 64-bit installation
- Install Ruby
install Rubyinstaller under win will be downloaded according to your computer system, for example, I was downloaded in 2014.11.25, version is Rubyinstaller-2.1.5-x64.exe. Of course, because it is developed by the Japanese, only Japanese and English versions, after the choice of accept agreement, enter the following interface:
note:
- be sure to put the middle Add Ruby executables to your PATH selected, the Ruby path is automatically added to the environment variable. Then install, ok~
- installation path to note that the first time the installation of the E:\Program Files\bla bla ... In such a directory, the following installation of rails will appear similarto the "'E:program is not an internal or external command such errors, and later found that there may be folders in the directory there are spaces can not identify." Finally installed directly in the root directory is good ~
Enter Ruby-v at the end of the command line to test:
hoho~~ Installation Successful ~~so easy~~
- Installing RubyGems
under win need to download the zip version of RubyGems, extracted after the execution directory of SETUP.RB, such as the 2014-11-25 download version is Rubygems-2.4.4.zip decompression: Execute Ruby on the command line SETUP.RB Command: After the installation is complete, test with gem-v : oh~yeah~
- Installing Rails
Remote Installation, if the network is not good enough, it will take a long time, so we will manually come to the ~ruby required gem in the rubygems.org site search download can (all the software here is the latest available version).
a) First you need to download the dependencies required for rails, and here you can see the dependencies required to install rails:
However, it is estimated by the installation time that several of these dependencies include other dependencies during the installation process, such as the view and model installed when the ActiveRecord is installed:
so the final dependency of the installation or in accordance with the previous version of the rails installation, to the following order to ~ ~
a) download the following activesupport
ActiveRecord actionpack actionmailer Rake Rails(the lower right corner has a download, Automatically download the latest stable version, 2011-11-25 is Activesupport-4.1.8.gem)
Place all gems under the same folder (e.g. C:\ror) after download
B) using the Gem install
Command
Install sequentially :
Gem Install Activesupport-4.1.8.gem
Gem Install Activerecord-4.1.8.gem
Gem Install Actionpack-4.1.8.gem
Gem Install Actionmailer-4.1.8.gem
gem install Rake-10.3.2.gem (will be prompted to overwrite Ruby Rake, the above Ruby version of the rake version is lower than this)
Gem Install Rails-4.1.8.gem
c) Test :
rails-v
Note:
found this sentence without:
DL is deprecated, fiddle
This is a warning information, do not care too much, but if you really dislike it can be removed, method: Remove the DL is deprecated, the use of fiddle warning message
- Create and run a web app
a) Create
use rails new
applicationname to create a new web app, such as go to app save directory Input command rails new Blog
bundle install command checks whether the dependencies in the gemfile are feasible.
then in the Save directory will appear named Blog folder, and contains some auto-generated files:
Note:
This step is likely to occur because of the implementation of bundles:gem::installererror:the ' json ' native Gem requires installed build tools ...
Workaround Reference:gem::installererror:the ' json ' native Gem requires installed build tools Error Resolution
b) Start the server:
Let's start with the Ruby on Rails server Webrick, in which the launch command is:
Rails s (or server)( executed in the app directory, For example .... \blog\):
then in the browser input http://localhost:3000 test it ~ ~
bingo~~ has succeeded ~ ~
Note:
If it appears:c:/ruby21-x64/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:182:in ' Rescue in Create_default_data_source ': No source of timezone data could is found. (TZInfo::D atasourcenotfound) error, please refer to:
data_source.rb:182:tzinfo::D atasourcenotfound
Solution
c) Run the application:
Rails is a framework written in the Ruby language, and can be understood by reference to the Rails guide.
start by using the Generate command in a newly generated application, rails g (Generate) Controller welcome index to create a controller named Welcome, as follows:
You can see that the corresponding controllers and views are generated under App/controllers and App/views. Edit View Index.html.erb, write something in it like ...
Blockquote style= "Background-color:inherit; margin:0px 0px 0px 40px; Border:none; padding:0px; " > then the play came ~ ~
Set the app's entry to the homepage:
open blog/config/routes.rb file:
where get ' Welcome/index ' is generated during the execution of the above rails Generate Controller Welcome Index command, the statement tells Rails to access http://localhost:3000/ The index action in the Welcome controller is executed when Welcome/index. Root ' Welcome#index ', which can be seen at the beginning of a line of root, removes the previous comment, which tells Rails to handle the index action in the controller welcome when it accesses the root path, and enters http://localhost : The contents of index will be displayed at 3000:
mom doesn't have to worry anymore. Ruby on Rails Environment ~ ~ Good Fun ~
Ruby on Rails installation (Win8 64-bit)