Ruby is not very popular, so it is difficult to draw conclusions at present. However, from the perspective of recruitment, there are still a few companies using Ruby. From the perspective of salary, Ruby is quite high compared with others, the main reason may be that there are fewer students. programming languages are universal. It is not a bad thing to learn a language more. I also gave a rough look at the basic syntax of Ruby at a friend's suggestion. I personally have the basics of c, php, and js, it seems that Ruby is not laborious. The first impression Ruby gave me is that the language is refined, the code is streamlined, there is no need to write semicolons, and there is no need to strictly follow the format like Python. This is different from other languages, as for the syntax, It is similar. Finally, I came into contact with the Ruby on Rails framework. To learn Ruby, I mainly learned this framework. Most php frameworks have more or less the ROR structure. In general, the Framework provides most of the functions. We only need to inherit the functions by ourselves. Developers mainly focus on design and business processing. The time is short and I have not yet seen the advantages of Ruby development, next we will describe how to install Ruby and Ruby on rails (ROR) as well as the development instance.
I am also a cainiao, so I have misstated Ruby. the first step of development is to configure the environment. I mainly learn from windows. The optimal development environment is Mac ox and Linux. In this aspect, the configuration is simpler than windows, and you only need to use commands to complete the configuration, if you are interested, you can search. download the Ruby for windows Version (http://Rubyinstaller.org/), and then install it. By default, install it under drive C Ruby, and then find the Start Command window in the Start Menu, this is the command window for simulating the linux environment. First we can see the Ruby version and the command for viewing is Ruby-v. Then we can check whether the gem-v version is later than 1.8, the command is gem update -- system, and then Ruby on rails is installed. gem is actually an application management software written in Ruby, and rails is also a gem package, next, we will wait for a long time to install rails. After the installation is complete, we enter rails-v to check that the version is now the latest version 3.2.4, and now the framework is basically completed, run the rails new C: \ weblog command to test the creation of an ROR application. The path is next to "new", and the weblog is the application name. We recommend that you use English letters. wait a moment, an application framework has been created. We opened the folder and found that there are many different names in it. Basically, we know what it means. In the future, the development will be mainly in the app folder, after opening it, I found a folder consisting of MVC pattern. This is the focus of future study. By now, the preparations have been completed, and we will demonstrate how the server runs.
With php, we know that the server can be apache, nginx, iis, etc. Of course Ruby is also supported, but here we use a small server that comes with Ruby, and input the rails server to start the WEBrick server, if it cannot be started, use the gem install WEBrick command to install the SDK. You can also use this command to install the SDK when other gem packages are not installed. the command can also be abbreviated as rails s. It can be started in a few seconds. At this time, the browser enters http: // localhost: 3000/to start the application, is a welcome page. The actual file location is in the public/index.html directory of the application directory. to change it to the startup directory, rename index.html as index2.html, create a controller, open another command window, and enter rails generate controller welcome index, create a welcome controller, index is the default startup method (Action), app/views/home/index.html. erb is the template file. Enter "hello" in the file and the file has been created automatically. We will then configure/routes. in the rb file, change the default startup method, find the similar statement "root: to => 'Welcome # Index'", remove # comment, and refresh the file to find that "hello" is displayed, however, the title and head are not in the template. In fact, this part is in app \ views \ layouts \ application.html. in the erb file, open it and you will see it. We can change this part of the public file. refresh a self-created controller and template again and it will be displayed. At this point, a custom controller is complete.
If you want to quickly write a blog, you can use the rails generate scaffold Post name: string title: string content: text command to generate it. However, we recommend that you define it for specific project development, currently, there are few video materials and some tutorials on the Internet for self-learning. Ruby is object-oriented, such as numbers and string boolean values are all objects. Learn the basic syntax, you can enter irb in the Command window to enter the Ruby environment and exit. If you want to write it in a file, for example, create test on drive C. rb file, the first line of input # encoding: UTF-8, the file is also saved as UTF-8 encoding, which can support Chinese characters, such as input arr =, 4] define the array puts arr output array to save, and then use cd or cd .. switch to the file directory c and enter Ruby test. rb can run the command just now. well, this is basically about learning to use Ruby and Ruby on rails in windows. The text tells you that you don't use any integration environment. There are several integration environments on the Internet, but the software version is very old, after the upgrade, it seems that the version is rails2, which is too different from rails3, so it is not difficult to install it by steps.
Ruby is still relatively small in the blog park, and it may be related to a small number of users. If you are interested in this field, you are welcome to talk about it. Any contact information can be found.
Finally, several commands are provided.
Irb enters Ruby command programming
Ruby commands
Ruby-v version
Gem-v
Gem update -- system upgrade
Install ror on gem install rails
Rails new c: \ web creates an application
Start WEBrick server on rails server
Rails generate controller welcome index create webcome controller
Edit recommendations]
- Top 10 New York tech jobs: Ruby developers with the highest salaries
- Tokushima Prefecture, Japan, uses Ruby on Rails to open-source official software.
- The father of Ruby, Song benhong's programming life
- Use Ruby and Twitter for Data Mining
- Ruby developers should be familiar with 10 tools