Slashdot Mirror


Part 2 of Ruby on Rails Tutorial Online

An anonymous reader writes "Curt Hibbs has released Part 2 of his tutorial Rolling with Ruby on Rails to the O'Reilly ONLamp site. The first part was published in January. Topics covered are database transactions, callbacks, unit testing and caching." From the article: "In Rolling with Ruby on Rails, I barely scratched the surface of what you can do with Ruby on Rails. I didn't talk about data validation or database transactions, and I did not mention callbacks, unit testing, or caching. There was hardly a mention of the many helpers that Rails includes to make your life easier. I can't really do justice to all of these topics in the space of this article, but I will go into details on some of them and present a brief overview of the rest, with links to more detailed information."

15 of 187 comments (clear)

  1. Python Version of RoR by grayrest · · Score: 4, Interesting

    http://subway.python-hosting.com

    It's rough, but it's coming along.

    1. Re:Python Version of RoR by Colonel+Panic · · Score: 4, Insightful

      Wouldn't that be PoR?

      Seriously, though, I really think that Ruby the language is part of what makes RoR so great. I'm not sure you can do a lot of the same stuff in Python as you can with Ruby. Being able to define natural looking domain-specific languages using Ruby's code blocks seems like something that would be very difficult in Python. But as they say, imiation is the sincerest form of flattery...

    2. Re:Python Version of RoR by Paradox · · Score: 4, Informative
      I can't impress you, sorry. But I can say that Ruby blocks are a powerful tool that are very flexible and useful. Ruby iterators are the showcase of this tool, and they're something you use every day in ruby. For example:
      ary = [1,2,3,4,5] # Example Array
      ary.each do |val| # Begin a block
      puts val.to_s + " was here!"
      end
      Blocks can be used inline as above, or turned into true closure-bearing functors like so:
      my_block = lambda { |x| puts x.to_s was here }
      my_block.call "Kilroy"
      ary = [1,2,3,4,5]
      ary.each &my_block
      You can write higher order functions that accept lexical blocks trivially. For example:
      def my_hof( &block )
      yield # Calls the associated block within scope
      block.call #Calls the associated block as a function
      end
      Also, ruby's blocks are used to do neat things like ensure things happen at the end of an operation. File I/O is the classic example. Check out how Ruby's library ensures your file closes:
      File.open( "somefile.txt", "w" ) do |handle|
      handle.puts "This is text in the file."
      end # File is ensured to be closed now
      This is just a small sample of what Ruby's standard lib does with blocks. They're really quite useful. They're like Lisp's lambdas but with a cleaner syntax when used inline.
      --
      Slashdot. It's Not For Common Sense
  2. Any interesting projects? by elh_inny · · Score: 4, Interesting

    Has anyone actually done some interesting stuff that now works in a productive environment?

    1. Re:Any interesting projects? by elmartinos · · Score: 5, Informative
      Shure! Even though Ruby on Rails is really very young, there are a few commercial sites that use it already. Here are a few links: Although, the first 3 links are somewhat related.
  3. Sounds exciting... by szlevente · · Score: 4, Interesting

    "A Rails web application can run under virtually any web server"
    Now that really made me curious. Is that really true, tried, and tested? If so, we need another bunch of tutorials about how to use Rails under Tomcat, Apache, etc. There is no way this framework will replace existing Java frameworks, but using it for prototyping is promising.

    1. Re:Sounds exciting... by rubycodez · · Score: 5, Informative

      No way this framework will replace existing java frameworks

      There is actually a chance it may become a mainstream way of building an enterprise framework. There is a very cool new bytecode Ruby virtual machine and just-in-time compiler (YARV), and the next generation of Ruby, Ruby 2, will support native OS threading. Unlike Java, the source for Ruby is and will be completely open & transparent. Ruby can run on platforms where java can't, like BeOS and MS-DOS.

  4. Rails and other Rails tutorials by teidou · · Score: 5, Informative

    To explain Ruby on Rails, I could say it is a highly integrated model-view-controller type web application framework. That would be like saying a Ferrari is a 4 wheeled internal combustion vehicle: true, but misses the point.

    For more info, see RubyOnRails.com. An good alternative tutorial is at http://rails.homelinux.org/.

    There are even better introductory materials coming. Dave Thomas (of Pragmatic Programmers) is working on a Rails book, chapters are being reviewed presently.

    Rails is powerful an flexible. More importnatly, it's a lot of fun. If you are a programmer who want to enjoy web-based application development, please do take a look at Rails.

  5. One thing has changed... by WWWWolf · · Score: 4, Informative

    When the part one was published, I had severe problems getting Rails to work in Debian. There was a lot of really odd tools that needed to be installed and all that. Rails web page had tons of Ruby packages that I was pretty sure I didn't need...

    But one thing has changed since then: Rails is now in Debian unstable!

    1. Re:One thing has changed... by Tobias+Luetke · · Score: 4, Informative

      Please don't make this sound like an rails or ruby issue. Debian really blew it on packaging ruby. Most of the system related problems which come up in #rubyonrails are related to debian linux installations.

      How did they come up with the brilliant idea to split the standard library into 34 different packages? I just can't see how something moronic like this can even get started considering that a standard library is all about raising the status quo of the language by providing some shoulders to stand on so people can reach for higher goals.

      Keep in mind that ruby has no dependencies at all. All dependencies are optional and the libraries using them (tk,x11, readline) fail gracefully with exceptions when the parts are not installed. Not so if the entire library is missing, this will cause a runtime exception with cryptic error message which rails will never be able to handle. Also ruby is tiny the entire package is 3mb!

      I heard they are talking about improving the situation by adding a "virtual package" for ruby which contains all 34 seperate packages

      Future in Debian terminology is traditionally not soon and thats a fix feeble fix considering all they need to do is to put all 3mb of ruby in one package

      Anyways the point is fairly moot now since debian doesn't have ruby 1.8.2 anyways which is required for the latest rails

      Luckily its easy to install ruby by hand. And I heard gentoo and freebsd install pretty easily too...

  6. ROR rocks! by Pfhreakaz0id · · Score: 5, Interesting

    As a guy who has written db-driven web apps in ASP, asp.net ( alittle), perl CGI, plain JSP/Servlet and j2ee app server with EJB's (both with and without a persistence framerwork/Object-relational bridge), I can tell you ROR is my favorite. I've only been using it for two weeks on a part-time project. It's ... beautiful. I can't think of any way to describe it. It. Just. Works.

    And ruby is a really nice scripting language. You should check it out.

  7. Re:What is this? by JamesOfTheDesert · · Score: 5, Insightful
    It's a collection of Java Best Practices rewritten in a 'cool' geeky language. Nothing new....

    Quite true. For example, Java Best Practice #1 is to avoid using long, detailed XML files for configuration, and instead use the programming languge itself, which is dynamically loaded and interpreted when needed.

    Another Java Best Practice is to let the framework write the tedious boilerplate code for you. For example, in Struts, you just run

    % struts myAppName
    and you're halfway done writing your Web application.

    Here's one more Java Best Practice: Avoid expensive , complex application server software, and do rapid development using the Web server that is built into the standard library. Then deploy to the Web server of choice with no code changes or quirky vendor-specific API hacks.

    --

    Java is the blue pill
    Choose the red pill
  8. Agile Web Development With Rails by Ridgelift · · Score: 4, Informative

    Dave Thomas' new book "Agile Web Development With Rails" is due out in July. It's really, really good so far (I'm one of the lucky ones who is helping review it). My perspective is a person who knows very little about databases, web application development and no previous knowledge of Ruby, the language that Rails is built on.

    One of the big problems with Ruby on Rails is that it is well documented, but a lot of it is API's and reference documentation. Dave's new book has an excellent tutorial which is the best thing I've seen written so far about RoR for newbies, and promises to go into the depth and detail similar to his Pickaxe book.

    If you've previously looked at RoR and were disillusioned because you just weren't "getting it " or didn't want to slug through the technical documentation, I encourage you to keep an open mind and wait until Dave's book is released. I'm finally getting over the hump with RoR and I now see what all the fervour is about.

    (Oh, don't ask me to post or send copies of his drafts, 'cause I ain't gonna!)

  9. Comparing RoR with Java solutions by MarkWatson · · Score: 4, Interesting

    I have worked through the RoR tutorial and re-implemented a simple admin web app that I originally wrote for a customer using JSPs and Tomcat. I must say that what took me 4 hours to write using JSPs and JDBC took about 30 minutes using RoR.

    A big advantage that Ruby and Python have over Java is that they are dynamic languages that makes it not too difficult to write a database wrapper class that dynamically looks at database/tables meta data and generates access methods on the fly. Java Tails (using XDoclet market tags) can't really compete.

    I really love the full J2EE stack for developing large scalable web applications but I am now looking at alternatives for creating smaller systems much more quickly.

    BTW, I really like RoR's templating scheme: much like JSPs in syntax (JSP non-XML syntax, that is) but do to Ruby's much terser notation for enumerating collections, the the templates tend to look a little cleaner.

    For Python, I really like the light weight CherryPy web application framework. I plan on checking out Python Subway also when I have some time.

    -Mark

    1. Re:Comparing RoR with Java solutions by dDrum · · Score: 4, Interesting

      There is a version of rails in java.
      It's called Trails and it uses spring, hibernate and tapestry.

      Site - http://trails.dev.java.net
      Tutorial - https://trails.dev.java.net/tutorial/"
      Trails in action - https://trails.dev.java.net/media/trails_withnarra tion.mov

      It's still beta but you can try it.