Just a quick question..
I can never get a definitive answer when googling this, either. Some people say you can learn Rails without knowing any Ruby, but at some point you’ll run into a brick wall and wish you knew Ruby and will have to go back to learn it..and some say to learn the “basics” of Ruby before learning Rails and it will make your life that much easier..
My current knowledge is low. I’m not a beginner, but I’m not pro, either. I went through the Learn Python The Hard Way online book in about a month, but I stopped once I got to the OOP side of Python (I know booleans, elif/if/else/statements, for loops, while loops, functions)
I agree with learning the “basics” of Ruby before learning Rails, but what exactly are the “basics” of Ruby? Would I need to learn the whole OOP side of Ruby before I went on to Rails? Or would I just need to learn the Ruby syntax up to where I learned Python (booleans, elif/if/else/statements, for loops, while loops, functions) before I went on to Rails?
Thanks!
3
Most people would recommend that you finish reading a book about Ruby first before moving into Rails, but if you already have a solid understanding of basic programming concepts from other languages (such as OOP, control flow, etc.), you can study Rails and just pick up Ruby along the way.
Most Rails books that are aimed for beginners assume that the reader doesn’t have knowledge in Ruby, so they tend to have a chapter dedicated to teaching the syntax of Ruby. Your mileage may vary. The key is to just dive in and see what works for you. You can study Rails right away and then study Ruby if you’re having a hard time or you can go with plain Ruby first until you’re comfortable enough to take on Rails.
If you ask me, I suggest you study Rails immediately since your motivation to study is to build web applications anyway. You’ll lose motivation if you study just Ruby since it takes a pretty long time to finish a book and be fairly adept in the language.
You can learn both at the same time. To learn Ruby, you will have to write Ruby code. You may as well be writing a Rails application as anything else. I had a copies of Programming Ruby and Agile Web Development with Rails. I skimmed Programming Ruby to get an idea of the language, then started following the tutorial in AWDWR.
If you only learn conditionals, booleans, loops, and functions, you can get a certain amount of stuff done. And probably, yes, you can get things done with just that knowledge. However, most of the code you write will be very procedural because you won’t know anything other than those procedural constructs. If you start writing a lot of recursive functions, one could argue you would be stepping up your knowledge.
However, if you really want to learn to program then you need to learn much more than just those things.
I am very happy that I went Ruby, Sinatra, Rake, then Rails.
Sinatra is a very useful micro framework that you will keep using even after you master Rails. Rake is an integral piece of Rails and understanding it prior to diving into Rails is beneficial.
I would suggest a similar route to anyone else.
First, a caveat: there is no definitive answer to this question.
Rails is more than just a framework. It’s a Domain Specific Language separate from Ruby, with its own keywords, culture, and idioms. A primary function of the Rails DSL is to hide things from you. Rails handles the abstraction between a model and the database, for example, so that you don’t have to write a data access model. So in this sense, Rails is simpler than Ruby–if you had to build a web application without Rails, you would have a huge amount of work to do.
On the other hand, every syntactically correct Ruby statement is a syntactically correct Rails statement. So the application logic that you write in Rails is Ruby, which is one reason people might say that you are going to regret not knowing Ruby. Rails implements a lot of Ruby’s metaprogramming features, so knowing what is actually going on in your Rails app requires some fairly advanced Ruby knowledge.
Another point is that the Rails framework implements the Model/View/Controller design pattern. Models are objects. Controllers are also objects. You simply can’t implement Rails without writing objects and calling methods on those objects. Most of what you do in a Rails app is write methods. If you don’t know what an object is, or what a method is, you might struggle with this. It might be good to understand objects before you try to understand a particular pattern of objects. On the other hand, it might be good to get a strict introduction to how to use a very specific pattern of objects before you try the general case.
On yet another hand, in my own experience as a guy who doesn’t know Rails, not knowing Rails is not much of a barrier to writing applications using Rails. It’s probably a barrier to writing good, well-designed applications in Rails, but if you know Ruby well, you can hack something together using any Ruby framework.
All of that said, the advice I would trust most on this is the advice at the Rails Tutorial Book website. The best piece of that advice is this:
a surprising number of beginners have used this tutorial to learn web development, so I suggest giving it a try
If you get lost, go back and learn some Ruby, or some HTML, or whatever you’re lost on, and try again! Learning Rails first isn’t going to stop you from learning Ruby later, and if you find that you need more Ruby, you can always put Rails down and pick it back up. There’s no wrong way to do this–do whatever keeps your enthusiasm for learning up, and whatever keeps you moving forward. Expect this to be pretty hard, though, whatever route you take. If it was easy, they wouldn’t pay us to do it.
In Ruby, I would consider OOP as a part of basics, because in Ruby, everything is an object. Definitely learn OOP (how to create a class, how inheritance works, class vs. instance methods, initializing objects…) before learning Rails. And modules – knowing how to create namespaces.
If you know Python, you should be able to pick up Ruby syntax in no time, it’s very, very similar.
Try to learn the fundamental points of Ruby. While you are doing this try to understand how things happen. For a better understanding you should always write some examples to each topic.
So most of the time you will see how things work.
After you are running fine with the major Ruby language features, you can switch to Rails and start to learn it from scratch.
I will list up the imo most important points that you should know about Ruby before starting with Rails:
- Variables
- String and symbols
- Operators
- Statements
- Loops
- Blocks/Procs/Lambdas
- Classes / Modules
- OOP
- Eigenclass/Singletonclass
There you go. If you are running fine with all that points i listed, then you can start with Rails. There you will notice that it was worth to put all the effort in learning Ruby before Rails.