문제

If I learn Sinatra or Padrino, does that help me with Ruby on Rails?

I assume that for all of these I need to get a better understanding of Ruby itself, but does (say) Padrino translate directly into skills I would use in Ruby on Rails or is it indirect?

I am a PHP programmer, but, as I have used PHP frameworks which are clones of Ruby on Rails, I am finding it not too difficult.

도움이 되었습니까?

해결책

This might be a more controversial opinion, and I'll admit to being new to both still, but as someone who just spent a week on Sinatra and then moved on to Rails, I would recommend going straight for Rails. Initially, it will seem like there's a lot more to learn about Rails, but if you're going to write something moderately complex, you're going to move to Rails eventually, and it's less work 'unlearning' from Rails what you need to write a Sinatra app than it is to relearn things to do it the Rails way. You save yourself the pain of having to shift gears when it turns out that your project you started in Sinatra was best done in Rails after all (which happened to me).

This does mean it's going to take a little longer to get up to speed on Rails. I recommend starting with Michael Hartl's tutorial and the official guides. However, my advice is specifically geared towards existing developers who already know how to develop web apps and are more likely to have more complex projects in mind than beginners. Someone brand new to web app design may very well appreciate the immediate gratification that building a basic Sinatra app will offer, but that doesn't seem to be you.

Experienced developers will probably argue that you can definitely write 'moderately complex' apps in Sinatra too, and they will be right. I think Sinatra's strengths are in being a fallback for experienced developers who want to knock out a quick app without Rails 'overhead', and not as an introduction to Ruby/Rails based web app development.

다른 팁

You can't skip the step to learn Ruby, because every Ruby MVC extend it, and if you have to do some important customization/optimization you'll do it in Ruby.

My advice is to learn a Ruby base (variables, blocks, modules, hashes,..), use Ruby on Rails in the real world, learn Rack and then choose the best "pieces" of the Ruby world that suit your needs.

Padrino is based on Sinatra, which in turns is based on Rack which is also the same ruby web server interface implemented in Rails. So yes, they have some common features, but no, learning Sinatra won't help you much in learning Rails if you don't learn Ruby before.

If you have used web frameworks before you are already familiar with MVC, templates and models. What you need to know now is the framework specific syntax so you need to work directly with the framework you want to learn.

Rails and Sinatra shares some common principles and habits which belongs to the Ruby ecosystem. But you would need to learn Ruby before in order to better appreciate these frameworks.

Don't assume the "learning Ruby" step to be an optional task.

Rails => Ruby => Sinatra => Rails

I did Rails + Bootstrap first, and while my deliverable at the end was really glossy, my ability to customize and upgrade was really shaky and REALLY REALLY slow. From there I moved onto the Ruby language syntax, some _why books and whatnot, and that sort of had me making sense of some things that initially just appeared as "magic bullets." After some time spent with Ruby I picked around at Sinatra, which was really fun. Sinatra made it possible to push a local server with a fully functioning webpage with a single page of code! It made it possible for me to experiment with databases and datamapper in a very intimate way. Currently I've shifted back to Rails, and things like scaffolding, model generation, controller generation, etc... these things are magic in a totally different way now. So I say:

  1. Rails

  2. Ruby Syntax

  3. Sinatra

  4. Rails

Rinse, Repeat...

I don't think Rails is a guaranteed final destination for a web developer using Ruby (though it is likely (: ). I worked with a software company that used Ruby and not rails for the web application. I started down a similar path as you (PHP). I wanted to develop using Ruby and began looking at Rails but found it pretty daunting. I started learning basic Ruby stuff and early in that process I discovered Sinatra. I loved it from the start. Learning using Sinatra allowed me to piece by piece add in various gems like an ORM or authentication and see how they worked individually. There are way less "moving parts" in an early stage app using Sinatra and for me that was preferred. I interact with a lot of Rails guys and from all I gather from our conversations I think it would be quite painless for me to develop a project using Rails now.

So my two cents is that for some people, learning Sinatra first may prove very helpful. But different people learn differently, so I don't think there is a one size fits all answer to this question.

Lean Sinatra, then Rails.

Rails has a lot of built in "magic" which means you don't really need to know HOW anything is working to get it up and running.

Next, when you decided to pick up Rails, you will have a better understanding of what is actually happening. The "magic" still exists; you just have a better understanding of how its doing its thing. This way if something breaks, you'll have a better understanding of how to fix it.

Good luck!

If you want to learn rails a good way is to follow the road map that is mapped out on this blog post. It is what I used and it was a great start. Obviously if you already know PHP there are steps that you can most likely skip, but overall it is a really good approach to taking little steps towards learning rails http://techiferous.com/2010/07/roadmap-for-learning-rails/

Just wanted to add my opinion that yes, learning Sinatra or Padrino will definitely help you learn Rails. In the sense that it will make the transition from PHP (or whatever) to Rails a lot less daunting. As wuliwong said, Sinatra and Padrino are way less complex than Rails. In fact, Rails is too complex for its own good in my personal opinion, routing in Rails is a bit of a nightmare, but let's not get sidetracked.

Also, while it is true that you cannot learn Rails without learning Ruby, there is no reason whatsoever why you couldn't learn Ruby as you lear Rails (or Sinatra/Padrino), it's a fun way to learn the language.

I started with Rails directly, with no knowledge of Ruby at all, coming from PHP. Did a lot of the tutorials out there, bought a few books and kept slogging on. After about 7 months of work with Rails I moved to Padrino to build an API and immediately loved its simplicity compared to Rails.

Once you get good, Rails has a lot of high-end magic that is awesome, but while you're starting out it's very overwhelming. Sinatra/Padrino allow you to start out smaller, easier and keep adding.

Good luck!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top