Preface
Today, when giving a lecture, Mr. Jiang talked about the development concept of Ruby on Rails, that is, happy programming. It is a pleasure to write code.
In the world of study, I don't feel how happy I am. I just don't have to go to work. Instead, I sat in the conference room and listened to my teacher's lectures. I felt a lot easier at once.
Let's get down to the point and start our Ruby on Rails journey.
Create an application named demo
1. Start instantrails.exe first, right-click the task box and right-click it to go to the open Ruby Console window. This shows a cmd interface, as shown in:
2. First, we use the rails command to create a new application named demo. In the above interface, enter: rails demo, the system automatically creates a demo folder under the rails_apps folder under the installation path of instantrails and creates a series of default files in its folder. In this way, the demo application is successfully created.
3. Next we need to create a hello method for the say control process to display the page. First, we need to connect to the demo folder and input: CD demo in the command line.
At this time, the path has been directed to the demo folder, and the command: Ruby script/generate controller say hello
As shown in (yellow area in the figure ):
In this case, we started the demoapplication service to display the content in hello.html, and typed the following in the command line: Ruby script/server.
5. After the demo application is started successfully, you can enter http: // localhost: 3000/say/hello in the browser to successfully access our application, as shown in:
6. Now the demo application can run.
7. We can modify it (Path: demo \ app \ views \ say \ hello.html. ERB)
For example, modify to: Hello, world! It is Ruby on Rails! Save and refresh the browser again. The displayed content changes:
Ror advocates to run it first ~ So far, our hello is available.