I leaned ruby, but the syntax and the file structure in rails is very difficult for me to understand, there are many things that I need to follow their "rules" to do, for example, I need t开发者_高级运维o generate the db using the migration... It is not suggested to do with typically typing SQL cmd, it makes me very difficult to move on... Any suggestion on how to learn the whole file and how the structure works? Thank you.
Rails is big, really big. It takes time to learn the intricacies of ActiveRecord (the largest piece of Rails by LOC). It takes time to learn how to test a Rails app. It takes time to learn how to build authentication/authorization for users. Keep working, it's worth it.
I can say from personal experience, before you can write effective rails code, you need to understand the routing system. To understand Rails routing you need to understand REST and the params
hash.
Run rake routes
to see all routes an app will respond to. You need to be able to explain what code runs when each of those routes is requested. You need to know what information will be passed in the params
hash for each of those routes.
Rails' migrations make changes to the database repeatable by you and others. Migrations make it possible to put changes to your database under version control, a must if you are collaborating with other developers.
Speaking of version control, you need to learn that too (if you haven't already). Maybe git, svn, or whatever you already know. This is not specific to Rails, but it's necessary to learning Rails.
If you're looking for a good intro text, check out railstutorial.org. I've worked through the entire book, cover-to-cover. The author, Michael Hartl will teach you everything I mentioned above. He will do it in tiny incremental steps, so it will take time. I really like learning from screencasts. If you do too, I can absolutely recommend the railstutorial.org screencast series. I am not affiliated with Hartl or railstutorial.org.
I found http://guides.rubyonrails.org/ to be great
I strongly recommend trying out Rails for Zombies. This is a wonderful tutorial that will not only show you how to use Rails, but will allow you to code in Rails directly in your browser, enhancing the learning process.
After that, I would go ahead and try Rails Tutorial Book. This will have you build a website that is basically like Twitter, allowing you to learn a massive amount of techniques.
Whenever you want to learn something new after getting the basics, I always find myself going to Railscasts to check out awesome screencasts by Ryan Bates.
Good luck, and welcome ot hte Rails community!
You may consider checking out RailsTutorial.org; it takes you from start to finish on a fully functional, test driven web application. This is the site I used to learn Rails, and it helped clear up a lot of the mystery.
Ryan Bates RailsCasts are the industry standard. Just search what you want to know about, and learn:
http://railscasts.com/
Look at the below site. It's quite helpful:
http://www.buildingwebapps.com/learningrails
all the best!!
This is a brilliant (and free) resource -
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
For a newbie, best way to learn Rails is to follow a book fro start to the end, and implement each of the examples in the book. I would recommend you following books:
Ruby on Rails 3 Tutorial-Learn Rails by Example
Agile Web Development with Rails
I find these two books excellent resources. Make sure you follow these books really well, one book at a time.
Following a book is much better practice than learning in bits-and-pieces from web.
精彩评论