Introduction to Ruby and Rails
Ruby is an object-oriented, dynamic scripting language. Its syntax is flexible and provides a rich library of classes. Therefore, the efficiency of writing programs in Ruby is very high.
Although Ruby was very early (born in Japan in 1993), Ruby has always lacked English documentation and Ruby was not very good at web development. So before 2000, Ruby was only popular in Japan. But all this was broken by rails, which came out in 2000.
Rails is a framework that is written using pure ruby. It provides strong support for web development, such as support for data mapping, MVC patterns, Web Services, security, and more. And these functions are much easier to operate than similar products, such as the MVC pattern, which is easier to use than struts. In addition to these, rails can also automatically generate Web programs based on templates. This will save us a lot of time. Before discussing how Ruby can quickly develop web programs with rails, let's look at how to install and run Ruby and rails.
Installing and running Ruby
Ruby supports multiple operating system platforms that currently support Windows, Linux, and Os X, and can download Ruby's installer and source code from Ruby's official website: http://www.ruby-lang.org/en/downloads/.
Under Windows for easy installation, it is recommended that you download the installed version of Ruby. After installation, there are two executable files in the bin directory in the Ruby installation directory: Ruby.exe and Rubyw.exe. The first one will start a console run Ruby program, and the second does not start the console running Ruby program. Let's start by writing a simple ruby program!
Build a text file: first_ruby.rb
Enter a ruby statement:
Puts Time.now.strftime ("%y-%m-%d%h:%m:%s")
Perform Ruby first_ruby.rb
If you output a string similar to "2006-10-07 19:20:20", Ruby is already installed successfully.
Note: Ruby has an eclipse plug-in that's pretty good, and if it's interesting, you can use Eclipse's Help->software updates->find and install functionality to pass through http:// Updatesite.rubypeople.org/release for installation.
Installing and running Rails
Rails is easy to install under Windows, simply by executing the following command:
Gem Install Rails--include-dependencies.
Note: The gem command is in the current bin directory of Ruby installation and the path path is set at run time. There is also the need to connect to the Internet when executing this command. Because this command is downloaded from rails and installed over the Internet.
After you install rails. Execute the following command
Rails first_rails
cd first_rails
Ruby Script/server