About three or four days of the rails learning path started.

Source: Internet
Author: User

Recently because of an aurora push friend, I started about three or four days of the Rails learning path, the final level is to be able to make most of the functions more easily, and then self-feeling can freely follow the design of rails to think. Because of the growing popularity of programming, I have met more and more non-computer students to start writing code for hobbies, but most of them may be using some wrong way of learning to learn programming, in order to avoid people to continue detours, in this article, I will introduce the next beginner how to learn rails.

1. What is the purpose of learning?

When I was walking with my friends today and talked about how to learn rails, the first question I asked was, why do you study rails, what are your goals for learning programming, and ultimately the outcome that you want to achieve is that any study may need to be clear. If the goal is to learn "universal" programs, whether it is to process data, or to learn the language itself, then I would suggest to abandon Ruby early into the arms of Python, although any language is Turing complete, but each language has its most suitable application scenario, Ruby relies almost entirely on rails to exist. OK, here we assume that the goal of your study is to be able to build a Web site, OK, we continue to say.

2. Learn Basic HTML knowledge

This is one of the things that most beginners learn about rails, and it's important to understand basic HTML knowledge. HTML doesn't need to be too esoteric, after all, we just need to get started.

If it's energy permitting it can take 1-2 days or so to quickly read through the book: Head first HTML and css my friend, the Aurora push, did that.

Do not need to read the details of the HTML tag and CSS style attributes of the details, only need to know all of the tags, to make the impression in the brain, remember some common tags, know how CSS works in HTML. Review when you open a Web page, pointing to the page that these are what the elements, the brain under the idea of how to write this page how to combine the label.

3. Learn to use the front-end debugging tools

Rails hides most of the HTML tags and uses its own template language, which is easy to develop, but does not add a layer of difficulty to debugging. So learning the front-end debugging tools is particularly important, common front-end debugging tools include Firefox Firebug, and Chrome's developer tools. Here take Chome's developer tools as an example, do not need to learn too much knowledge, understand the common operation can.

Know how to view the HTML source of the corresponding tag, and then try to modify some of the corresponding CSS styles on the right.

Learn how to view network requests and common status code meanings, such as 200, 304, 500, and so on.

4. Learn about common database operations

Before we learn rails, we need to learn the basics of the basic stuff, and the final step is the basics of the database. Here, I personally more recommend MySQL, the reason is more information, in their own computer to install a MySQL, do not learn too deep, follow the tutorial to understand the basic concept of the database: libraries, tables, rows, columns. Then follow the tutorial to learn how to create a database, create a table, basic additions and deletions can be changed. Also recommend an introductory book bar official website visit Aurora Push to see:

Don't have to read it all, see the eighth chapter is almost enough. After all, rails has a perfect database operation package, learning more about MySQL or debugging.

5. Learn the basic concepts of rails

Well, I guess the above steps should take you about three days, and finally you can start learning rails. Rails has a clear learning guide that doesn't need to read, so here's what it's all about: http://guides.ruby-china.org/getting_started.html But this is more for the basic people, if there is no language foundation, Just follow this tutorial and you'll find that you have no extensibility, and it's hard to do other projects. (This is also a problem I find a lot of people) we might as well have some exercises in the tutorial. The following is only for the idea, the specific can own control.

Let's go down one step at a pace, install Rails, use scaffolding to create a blog program, and Hello rails. OK, after the fourth step, please stop for a moment. Here we print out Hello Rails, but let's start with a practice: Here you can use the HTML/CSS knowledge to make a relatively complex welcome page, then add the navigation bar and jump to a about page based on the navigation. Here are two questions to consider:

1. How does the Rails routing work

2. How does the Rails page template work?

Then we continue with the tutorial, complete the 5th step, and here we do an exercise again:

A. Change the database from SQLite to MySQL and store the data in MySQL.

B. Every step of the operation to remove or delete the change check in MySQL see the changes

C. Add a field to the article, such as author. Then learn to do the corresponding changes, after running the migration, see what happens to SQL in migrate.

D. View the HTML generated by rails from the browser to see what Web requests have occurred each time a commit or modification request is sent.

E. Add a put print operation to your handwritten code, print different variables, and learn basic debugging techniques (e.g. intentional error, then print the result). For example, add puts Article_params in the middle of the statement

F. Close the tutorial, standalone operation added a "Add user", "Logout user", "Modify user" and other similar features. Review the previous action.

G. Think about some of the issues, how rails works, what the rails do, what the route, controller, view, model exactly works, generate, Rake, and so on, what do we do with the commands we used, and verify the confirmation. Hopefully here you can draw a picture of each of the components of rails, the meaning of each, and the parts that each command affects.

Continue to complete the remainder, and part six is to complete the correlation of the two models. Similar to the above practice:

A. What do we do every step of the step? What do you do with the database?

B. If you want to associate the article with the author, how to modify the whole program.

C. What happens to the corresponding database? We do not think from the perspective of rails, simply from a database perspective, then why these tables are designed.

D. If you want to give the article what is the relationship between Tag,tag and the article, how to modify the program, the database becomes what it looks like.

E. What if the tag is called by the user? What about the program?

F. I believe that the above operations, will encounter a variety of problems, the use of Google and StackOverflow, but the problem is meaningless, to think about why this can solve the problem, and then think clearly to give yourself a similar problem to solve themselves. Also, be good at debugging problems with puts printing. (although it is very earthy, but very useful)

6. Some questions about learning rails

A. Learning a language the most important thing is to learn the design concept and world view behind the language. This is also a point I hate rails, rails more emphasis on the Convention than the configuration, expect you all follow his steps to work, so we are learning rails, the greatest need to do is to try not to write code, put down the feelings of those feelings of insecurity, I believe he will always help you do.

B. Object-oriented design architecture. Whether it's Django or rails, it's all about the object-oriented design concept. When we build a project in the traditional way, we will first think about how the database should be designed when we design this product, and then how to write our SQL statements. But rails discards the implementation details of the database (which is by no means a simple SQL), for example, in the above example, we only need to know clearly that a blog will have multiple comment, an author will have multiple blogs, and how the bottom of the corresponding implementation to the rails framework. So we need to abandon the language details and think about the whole relationship from the perspective of "object".

C. Do not struggle with the Ruby grammar itself, for beginners, do not struggle with the Ruby grammar itself, I believe most people have at least a computer two to learn C language, because most of the functions of the addition to add up and change to check only, adding up the statement is so much, so write, then meet the function to check, Then remember that enough to handle most of the problems. As for Ruby syntax, wait until the advanced stage to read it again.

D. It is important to be aware of the functionality of each component of rails, what is going through in a browser's URL request to the last HTML page, and what it has gone through in front of the user.

E. Practice repeatedly. Do not covet too much content, in fact, the above introductory guide has been able to solve 80% of the problem, please have a page function repeatedly polished this page, such as adding authors, such as the deletion of comments, such as comments, such as to add comments, such as the end of all comments with a smiley face and so on.

F. Multi-print, print look at a variety of variables, deliberately make mistakes, know that it will be wrong and guess the error message is a very worthwhile thing to do. This will make it easier to understand how the entire framework works.

7. Written in the last

I have not been very sympathetic to rails Girl, Django Girl activities like this, at least not in their teaching model. What exactly is programming? Make a Web page? Actually I agree that everyone learns to learn programming, but because programming is the most important problem-solving ability, knowing how to do it and why it is much more important than doing so. When I see a lot of people follow the tutorial to complete a seemingly stunning function, I have to say, in fact, there is no point, I do not think this can cultivate so-called interest. Thinking is far more meaningful than doing it.

I hope everyone is programmed happily.

Aurora pushes flying Forest sand

About three or four days of the rails learning path started.

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.