Rails 2.0, the latest version of the framework for the Ruby language, is made for doing REST applications, says Mike Clark, author of the newly released "Advanced Rails Recipes: 84 New Ways to Build Stunning Rails Apps".

By submitting your personal information, you agree to receive emails regarding relevant products and special offers from TechTarget and its partners. You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.

In my experience, developing applications for the last 15 years, Rails is the quickest way to get a Web application ready. Mike ClarkAuthor"Advanced Rails Recipes: 84 New Ways to Build Stunning Rails Apps"

"As of Rails 2, REST is very much a core idea and implementation in Rails," Clark explained. "David Heinemeier Hansson, the creator of Rails, began getting the REST bug many months ago. He was looking at the Atom Publishing Protocol and getting deep into REST. So when you're working with Rails 2 today and you're using the facilities inside of Rails, things like Scaffolding to put up a Web application really quickly, all the code generation in Rails is building a RESTful application."

The Rails creator is positioning it as "REST out of the box," Clark said, but notes developers are not locked into it. "You can certainly write a non-RESTful application. That's easy to do as well, but Rails and REST go together because David believes that's the way to build Web applications."

In keeping with that emphasis, Clark said the first recipe in the new book covers how to create a RESTful application. The recipe book is not however the best text for beginning Rails programmers, he explained. Compiled from recipes written by 50 contributors in the Rails community, it is designed for programmers who have experience with Rails, but are looking for help with specific application issues, the author said.

Asked what it would provide for a coder wanting to do Ajax with Rails, Clark said, "You can look for an Ajax recipe, but you're not going to find a recipe called 'Add Ajax to your project.' What you will find are recipes like 'How do I do Ajax and a checkbox in a RESTful application?' or 'How do I Clean up Ajax calls using Rails?' So the recipes are very specific about how do I get a job done. They are not general like how do I build an Ajax application."

The author suggests that developers looking to try Rails for the first time start with a more basic book.

For those who are not working with the Ruby language and the Rails framework, the almost inevitable shorthand among coders has shortened Ruby on Rails, as it was originally known a few years ago, to simply Rails. But Clark said that is "just sloppy speaking on our part."

"One of the unfortunate things is a lot of people confuse Ruby and Rails," he said. "In much the same way that J2EE is a Web application framework built in Java, Rails is a Web application framework built in Ruby. In the same way that Java is an incredibly powerful language in its own right outside of Web applications, the same holds true for Ruby. Ruby is a wonderful object-oriented language. It's a general purpose programming language. Rails is built on top of it."

If he had his druthers he would call the combination Rails on Ruby.

"Rails is a Web application framework that is powered by the Ruby language, and gets much of its features from Ruby," Clark explained. "A lot of the cool things about Rails come from the Ruby dynamic language. So it's hard to re-do Rails in other languages. So whenever people talk about Rails, they're really talking about Ruby on Rails."

Moving from Java to Rails A developer for 15 years, Clark moved from Java to Rails several years ago when he worked on projects for online bookstores. Among his projects are The Pragmatic Bookshelf, an imprint of The Pragmatic Programmers LLC, which sells print and downloadable PDF versions of books, including his Rails recipe book.

Working with Dave Thomas, one of the founders of Pragmatic Programmers, and Web designer John W. Long, he helped convert the entire online bookstore to Rails.

"Last year, we started converting that site," he explained. "There were a bunch of different technologies powering that site with a bunch of separate little applications. We converted it over to a Rails application. When I say 'converted' it sounds like it was just a port, but it was actually pretty much a complete re-write of everything to get it all into a nice cohesive application. We added tons of new features that the site didn't have before. It's really a completely different application. At the end of the day, it's still offering books for sale. But we've got discussion forums and the ability to regenerate PDFs and basically the entire infrastructure for the Pragmatic Bookshop."

Clark's first experience with Rails was working on for Vital Source Inc. to develop an online store that sells e-books only on a model that might be called iTunes for books.

"I cut my teeth on Rails with that project," he recalled.

Asked what led him to move from Java to Ruby, he said that for all the power of the former, the later was created with coders in mind and is easier and frankly more fun to work with.

"Ruby has this thing called the Principle of Least Surprise," Clark explained. "What that means is things should just be intuitive to do. Things should just work. You shouldn't have to do a whole bunch of extra stuff to get something done. And every once in awhile, you're surprised how easy and fun it is and that's the power of the Ruby language. Rails does that too. It takes the grunt work and it moves it aside. It says we're going to adopt some conventions, and as long as you're cool with the conventions then things are going to go much smoother for you. So you can really concentrate on what you intend to do, which is build an application. You can really concentrate on your domain and the things you want to add to your domain and not have to concentrate on all the plumbing and configuration things."

Ruby for quick database mapping For example, he points to a Ruby feature that allows the developer to quickly do database mapping as one of the plumbing issues taken care of by the language itself.

"It sounds kind of trite, but that adds up to a whole lot of timesaving," he said. "When you're not configuring things and having to hook up this and that, coming up with your own conventions and your own directory structures, it means you have a ton more time to do the really important stuff."

Members of the Rails community are cautious about using the term "enterprise application," but having help build two online bookstores, Clark says Ruby, Rails and REST are ready for real world applications.

"In my experience, developing applications for the last 15 years, Rails is the quickest way to get a Web application ready," he said. "And they're not throw-away applications. They're not quick and dirty. You get them done quickly, but they also have things like testing built into them. Rails makes it easy to write tests. The whole model view architecture means you're design is flexible. So it has a lot of best practices principles built into it. So it's not a quick application that you throw away. It's something you get done quickly, but at the same time it's very malleable and very maintainable. If I do it right, of course."

E-Handbook

0 comments

E-Mail

Username / Password

Password

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy