Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Technology

Rolling With Ruby On Rails 406

Bart Braem writes "The Ruby community is abuzz about Rails, a web application framework that makes database-backed apps dead simple. What's the fuss? Is it worth the hype? Curt Hibbs shows off Rails at ONLamp, building a simple application that even non-Rubyists can follow."
This discussion has been archived. No new comments can be posted.

Rolling With Ruby On Rails

Comments Filter:
  • by Anonymous Coward
    Ruby doesn't have FlexGrid ocx which basically makes it useless for database apps.
    • Ok from my googling FlexGrid is a framework that automatically adjust data elements alignment/scrollbars/size etc to fit certain formatting.
      I've never used it so I have no idea how good it is, but I'm sure there are similar things, in other languages. But to say that a database app is useless without it is just plain silly.
    • FlexGrid? (Score:5, Funny)

      by ackthpt ( 218170 ) * on Friday January 21, 2005 @12:57PM (#11433646) Homepage Journal
      Ruby doesn't have FlexGrid ocx which basically makes it useless for database apps.

      FlexGrid? FLEXGRID?!?!

      Implementation of FlexGrids is responsible for extreme stress, male pattern baldness, genital warts, dry heaves, infertility, webbed toes, seeing spots, loss of super powers, carpal tunnel syndrome, diarrhea, dandruff, dispepsia, gas, fingernail rot, yellowy wax buildup, stink foot, Plantars warts, incontinence, communism, crusty boogers, arthritis, bursitis and and cooties. The only treatment is 500mg of Dammitol, fiftytwo times a day.

      You, sir, are a maniac.

  • Nice framework... (Score:2, Interesting)

    by Anonymous Coward
    Looks good, nice to see some competition in the database backed web applications category for Java/PHP/Perl. However, I'm dubious about the claim that it's "ten times" faster than Java. It may be a bit faster, sure, but the amount of code doesn't look hugely less than what you might write to create a simple application using one of the many JSP/Servlet frameworks available.
    • Besides, if you do things The Right Way, when programming in OOP, the design takes a huge part of your time... and I don't really see how Java or Ruby differ in that...

      • Lets just say the Java Developers (the ones developing Java, not with Java) didn't take the time to do OO in Java The Right Way (TM).
        • Hoo boy! He're we go. Another shot across the bow in the never ending OOP Wars of Religious Supremacy. Back away ten paces, ready your Smalltalk and C++ code and come out firing.
      • by JamesOfTheDesert ( 188356 ) on Friday January 21, 2005 @03:26PM (#11435367) Journal
        Besides, if you do things The Right Way, when programming in OOP, the design takes a huge part of your time... and I don't really see how Java or Ruby differ in that...

        Um, yes and no. If your point is that there is a certain amount of abstract thinking required before you write any code, then yes, they will share a comon process. But, after coding in a language for a while, you tend to start thinking in the terms and abstractions the language facilitates.

        So, in perhaps the common case, Java designers will soon be thinking in terms of factories and adaptors and filters and all sort of entities that are often required in Java but which are extraneous in an agile language.

        And the time spent on those extranous objects is not time spent adressing the actual problem, but time wasted working around or through the demands of Java.

    • by Anonymous Coward
      Wow, you obviously haven't used Rails. It *IS* much faster than Java. Hell, anything is much faster than Java.

      When you add something to Java (a new controller let's say), you have to configure it in a big XML file (with most if not all of the frameworks). Or a new template. Or a new model object. In rails you don't have to do any of that, it dynamically finds it! You literally *fly* in Rails (partly because of Rails, partly because of Ruby).
      • by tundog ( 445786 )
        In rails you don't have to do any of that, it dynamically finds it!

        Thats a great concept as long as everything goes as planned. But wait until it 'dynamically finds' the wrong thing. Try debugging that nightmare. (Think VB Script + Option Explicit).
        • by Paradox ( 13555 ) on Friday January 21, 2005 @01:00PM (#11433674) Homepage Journal
          Firstly, Rails's ActiveRecord class is very simple Ruby code, so it's naturally bug-resistant.

          Secondly, the author knows that ActiveRecord could be a source of problems, which is why it's got dozens of unit tests, covering nearly every line of code.

          Thirdly, even with all that bugs can and will sneak through, which is why ActiveRecord can, upon command, write a detailed log of its attempt to dynamically bind and create the classes you want. The logging is at the message-passing level of Ruby, which is nearly as atomic as you can get (you could hack the interpreter to go further, but that'd be pointless).

          The dark ages of hideous bugs in dynamic code are gone my friend. We have the tools and techniques to make code of this type both safe and maintainable. Don't be afraid of it.
      • It's not that big a deal, really. I wrote a custom web application framework for an iAnywhere product that did exactly what Rails is doing, but in Java. Basically it mapped the path in a request to a set of classes. The mapping was determined at runtime through reflection. Worked well, you could do some neat stuff using inner/nested classes. The parent always got first crack at a request, so it could do filtering before the child was called and also of the child's results.

        The disadvantage of doing this st

    • Re:Nice framework... (Score:4, Interesting)

      by Paradox ( 13555 ) on Friday January 21, 2005 @12:55PM (#11433619) Homepage Journal
      Sir, may I ask you exactly how you're going to get your Java framework of choice to connect, comprehend, and dynamically bind to a SQL table in only 2 lines of code? Because that's what you're going to have to do to beat Rails in code count. For instance, if we have a table called "Clients". It has lots of fields.

      If we want to link it to Rails, we'd use the following code:

      class Client < ActiveRecord::Base
      end
      Yeah. That's really it. And you can specify relations with a simple micro-language in the class declaration (that's based out of ruby syntax). Once you've done this, you can write code like this:
      my_client = Client.find( 26 ) # Find by primary key
      my_client2 = Client.find_by_manager_id( 12 ) # Find by some field

      # This code prints out each client's id and name
      Client.find_all.each do |c|
      puts "#{c.id}: #{c.name}
      end
      And Rails makes the action mappings just as simple. I'd eat my old shoes before I'd believe that there is some lurking JSP/Servlet framework that has evaded my sight (and everyone's sight, really) that can do better. I know Java's limitations pretty well.
      • Hibernate does take care of this nicely, but certainly not with 2 lines of code :)
      • This is similar to Java DAO and to an extent EJB though EJB's have a lot more complexity due to being remotely accessible. You can wrap EJB's in a DAO framework.

        While DAO isn't dynamic, there are a good number of DAO generators that will build your classes and interfaces based on your database schema. Then your database access becomes pretty simple. You call up your daofactory to get the sepcific dao object then make the calls to it just as in your example.

        I wrote a dao generator for some projects th

        • What's cool about Rails, and why this dynamic approach is so desirable, is that it can change on-the-fly.

          Yeah, you heard me right. Your web app can be depolyed, and you can modify the tables. Need to add a new field? Just do it. You can also (on-the-fly) make new test actions to play with these parts of the database. Of course, deleting or renaming a column can cause a problem with existing code, but Rails still gives you more than most competitiors in this regard.

          Being able to debug a web application wit
          • Your web app can be depolyed, and you can modify the tables. Need to add a new field? Just do it. You can also (on-the-fly) make new test actions to play with these parts of the database.

            You call that a feature. I call that a symptom of an inherent design flaw.

            The whole Ruby-on-Rails framework seems predicated on the idea that the application (and hence everyone on the internet) has unfettered access to the database. There's no way in HELL I'm granting an untrusted user (someone on the internet) per

              • The whole Ruby-on-Rails framework seems predicated on the idea that the application (and hence everyone on the internet) has unfettered access to the database.

              Rails does not assume this. Rails only does what you let it; if you write data-reading code, the connection must have read access to the DB, and if your code updates the data, the connection must have write access.

              You how structure and delegate this access is up to you.

              • The phrase "stored procedure" doesn't even seem to be in the R-o-R develope
        • Rails is not just a framework for accessing a database.

          There's also ActionPack (http://ap.rubyonrails.org/), which is the View and Controller of the MVC pattern (ActiveRecord being the Model part).

          The integration between the two frameworks is what makes Rails so impressive.
  • Played with it (Score:5, Informative)

    by tenchiken ( 22661 ) on Friday January 21, 2005 @12:16PM (#11433216)
    And did a quick application with Ruby on Rails already. If you are confortable with Perl, you may find this easier to deal with then Python and it's love of whitespace. The object model is much more developed then either python or perl, but it still retains much of the flexability of the other two systems.

    Ruby has already inspired a few efforts to duplicate the technology in Java and in .NET. Since the core technology behind RoR is open classes, and the ability to add accessors and functionality on the fly, the other languages just don't cut it.

    The usual warnings apply. Implicit code is easier 90% of the time, but that other 10% is painful to debug. With large projects you can prototype fast, but maintaining may be much more difficult.
    • Re:Played with it (Score:3, Interesting)

      by rainman_bc ( 735332 )
      Kind of off topic, but I still have a hard time wrapping my head around the idea of passing code blocks to functions... It's really a strange way of doing somethings IMO...

      Not that it's bad, it's just an interesting programming paradigm, and one that would take some getting used to.

      Rails seems like an interesting. Am I correct in think it's like mixing mod_ruby with an app framework?
      • Re:Played with it (Score:5, Informative)

        by Merk ( 25521 ) on Friday January 21, 2005 @01:24PM (#11433953) Homepage

        Once you get used to the idea of passing blocks of code around, you'll love it, and won't be able to go back to Python... er... I mean, won't be able to go without it.

        The canonical example is the iterator. Given an array pets containing ["dog", "cat", "fish"]:

        pets.each { |pet| puts pet }

        Will return
        dog
        cat
        fish
        If you want to print out the uppercase versions

        pets.each { |pet| puts pet.upcase }

        Or if you want to add some text:

        pets.each { |pet| puts "I love my pet #{pet}" }

        Big deal, right? Not much different from a for loop. But blocks are amazing when dealing with things like a database. You can put all the setup, teardown and error-handling code in a method that's hidden from the user, and all they have to do is pass in the block they want the DB object to execute:

        require 'dbi'

        DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') do | dbh |

        puts "inserting..."
        sql = "insert into simple01 (SongName, SongLength_s) VALUES (?, ?)"
        dbh.prepare(sql) do | sth |
        1.upto(13) { |i| sth.execute("Song #{i}", "#{i*10}") }
        end

        puts "selecting..."
        dbh.select_all('select * from simple01') do | row |
        p row
        end

        puts "deleting..."
        dbh.do('delete from simple01 where internal_id > 10')

        end

        Unfortunately, slashdot eats my indentation, but fortunately, Ruby not being as picky about whitespace as *some languages*, that doesn't matter. Note that all that code is wrapped in a DBI.connect() call, which connects before it starts executing the block, and disconnects after. There's no "close" call required, it's all wrapped up for you.

        • I just used my last mod point this morning. PLEASE somebody mod this post up.
        • Thanks so much for that - like I said it's neat, but hard to wrap your head around... You've bade it a bit easier.

          I've been writing in VB for a long time, so the dot notation, and the lack of semicolons have made it a good candidate for the transition. That was the only thing that was driving me nuts...

          Hope you get modded up - that was probably one of the most informative Ruby posts I've seen.
  • Look all of you LAMP users... You can do the same thing using Ruby that you can do with whichever P in LAMP you prefer (PHP, Perl, or Python)! Can we change our name to onLAM{P,R} now?
  • Rails is a big deal from the stand point of a world where Java frameworks are considered state of the art. However, the big breakthrough with Rails will come when a Rails-based REST web services generator presents the database schema to a client-side ECMAScript XForms/templating solution.
    • You know, the parent probably isn't a troll, but it sure reads like one to me. I guess I'm just too far away from the state of the art over here. I've lost my buzzword compliance.
      • I wonder whether there are any metrics you could apply to rate the signal-to-noise ratio of a given word. For example, "XML" is virtually all noise given the fact that its basically just a syntax for named parenthesis but it is used in so many contexts you could get the idea that it is everything from a programming language just a fancy form of HTML.

        Of Rails, XForms and REST web services, REST web services is probably the noisiest of the terms but it is so limited in scope that there probably isn't too m

  • I don't mean this as a "let's bash Windows" kind of argument. It is just that, if you aren't running Windows, you'll have to make a lot of adjustments in reading this article. Just a heads up. If you are using Windows though, looks like this could be very useful. If not, it could probably still be of use anyway.
    • I think they're just using the windows stuff as a sales pitch to Windows people. It says, "In most frameworks, this part of the application can grow pretty messy, tedious, verbose, and error-prone. Rails makes it dead simple!" That's marketing language. The toughest job is convincing non-technical managers. They will often look at something without a simple GUI installer like something from the dark ages. To them, presentation conveys product maturity and professionalism.

      Let them chew on RoR on their WinXP

    • by MooseByte ( 751829 ) on Friday January 21, 2005 @12:41PM (#11433477)

      "If you are using Windows though, looks like this could be very useful."

      Only if it can match the stability and security of IIS that we've come to depend on. Otherwise it's just another shoddy product built by communists for communists.

  • by Anonymous Coward on Friday January 21, 2005 @12:19PM (#11433259)
    A categorized collection of ruby links can be found here in a nicer format:

    http://www.rubygarden.org/ruby?RubyOnTheNet [rubygarden.org]

    Interactive ruby resources:

    irc://irc.freenode.net/ruby-lang - the #ruby-lang channel is popular. More info at RubyOnIRC

    http://www.ruby-forum.org/bb/ - a forum for ruby novices to ask questions

    news://comp.lang.ruby - the ruby newsgroup

    Ruby websites:

    http://www.ruby-lang.org/ - ruby home

    http://www.ruby-doc.org/ - ruby docs and online reference

    http://www.rubyforge.org/ - rubyforge ruby projects

    http://raa.ruby-lang.org/ - ruby application archive

    Ruby Code Examples and Snippets:

    http://pleac.sourceforge.net/pleac_ruby/ - ruby pleac

    http://www.rubygarden.org/ruby?RubyOnlineCookboo k - ruby cookbook

    Popular ruby and ruby-related projects:

    http://rubyinstaller.rubyforge.org/wiki/wiki.pl - ruby installer for Windows

    http://rubyforge.org/projects/rubygems/ - rubygems ruby package manager

    http://www.yaml.org/ - ruby 1.8 includes built-in yaml support

    http://www.rubyonrails.com/ - web framework in ruby

    http://rubyforge.org/projects/instiki/ - wiki in ruby
  • by MrAsstastic ( 851637 ) on Friday January 21, 2005 @12:19PM (#11433264)
    Back where I am from, using rails all night to code a project can land you in trouble with the law, drain you financially and mentally, and leave you with a nosebleed. Best stay away from this nonsense.
  • by Anonymous Coward on Friday January 21, 2005 @12:20PM (#11433277)
    The biggest drawback to RubyOnRails is that you wont find it installed on very many webhosts.

    I given it a testdrive, and RubyOnRails is an amazingly fast and powerful way to develop webapps, but even so, it's been around for a while and still 99% of webhosts only stick to tomcat & PHP/MySQL, so that's what I code for. Even Python w/o Rails has more ISP support.

    My question is: When will RubyOnRails get "popular enough" to make inroads? I'm looking forward to it, because it means I can be way more productive and get a head start on all the other PHP "solution providers" out there.

  • Ruby On Rails (Score:2, Interesting)

    by ezmobius ( 837619 )
    This framework is very nice. If your looking to get away from the sometimes mess of php web development, then this is a great choice. Ruby is a very expressive and powerful language that is very easy to read and code. And also very easy to make wrappers for c libraries. The rails framework does make it _very_ fast to develop MVC web apps with a small amount of intuitive code. And the rubyonrails mailing list is very active and friendly.
  • by Metteyya ( 790458 ) on Friday January 21, 2005 @12:31PM (#11433381)
    I like Ruby, even before I got to know Rails. The only thing I regret is that LAMR sounds really bad.

    I develop webpages with LAMR - imagine saying something like that ;).
  • That's great if all I want to do is maintain a database through a web interface. I don't. Most of my work involves complex modification of that data, or calculations based on it.

    Does Rails help with that?

    Don't get me wrong, I've got some simple PHP lying around this could replace brilliantly, but first impressions are it doesn't help with the really complex stuff.
  • by Paradox ( 13555 ) on Friday January 21, 2005 @12:34PM (#11433409) Homepage Journal
    Rails is an incredibly good framework for Ruby, that really shows off its power and makes it easy to get a web application going, but it's not all that Ruby has to offer.

    Ruby is full of incredible libraries and frameworks like this, especially where text processing and web development are concerned. It's because Ruby has such a rich set of features.

    Anyone who likes Rails should dig deeper. Heck, Ruby's standard library comes with some amazing things. Ruby also has a framework called RubyGems [rubyforge.org],
    which is very much like Perl's CPAN integration or CommonLisp's ASDF framework.
  • Any comparisons to Hibernate stacks, Struts, Zope3, CherryPy etc?

  • Rails is awesome (Score:5, Interesting)

    by swimmar132 ( 302744 ) <joe@pNETBSDinkpucker.net minus bsd> on Friday January 21, 2005 @12:58PM (#11433652) Homepage
    I've almost finished developing a real estate site using it. First time using Rails.

    In PHP or other related language, probably would've taken me about 80 hours or so to develop the site. In Rails, I've spent maybe 15 hours or so total on it. And I'm charging $8k for the site. Admittedly, that doesn't include time working on the graphics or design of the site, just the backend, search, etc.

    So if you look at it from one perspective, I went from making $100 an hour to $533 an hour using Rails!
    • And when you get run over by a bus, who'll be able to maintain / update your site? Is there a large enough base of Rails users such that your client can find another developer?

      Not trying to knock what you've done, but if I were your client, I might be happier knowing my site was written in a more common language...

      • Re:Rails is awesome (Score:3, Interesting)

        by swimmar132 ( 302744 )
        Considering that I've written less than 500 lines of code (not counting html or css), I'd guess pretty much anyone could get up to speed with it in less than a day, even with Rails experience.

        Hell, I probably only spent two days studying Rails prior to creating the site.
      • by Anonymous Coward
        Oh please, not this fallacy. Just put an ad out for a Ruby programmer. Do you really think there are only about 5 or 6 in the world or something?

        And what makes you think Java or PHP or whatever is magically maintainable because the language is familiar? It takes me at least a week to get comfortable with another developer's layout, structure, conventions, etc. It might as well be a different language anyway.

        Besides, any good programmer could learn Ruby in a weekend. It's a *simple* language.
  • 1. Download the latest One-Click Ruby Installer for Windows (shown in Figure 1). As of this writing, the latest is ruby182-14.exe).
    2. Double-click on the downloaded executable and follow the installation instructions. Unless you have some special needs, just press Enter to accept all of the defaults.

    Believe me guys, no hype at all :-).
  • TMTOWDI (Score:5, Insightful)

    by ryantate ( 97606 ) <ryantate@ryantate.com> on Friday January 21, 2005 @01:09PM (#11433788) Homepage
    Perl has its own rapid application development framework, Maypole. Here are some screenshots [perl.com] from a Perl.com article where Simon Cozens sets up an online sales catalog in 11 lines of code. (Here's a followup article [google.com], and the Maypole home page [google.com].)

    These systems all demo well because the developer gets to decide what functionality to demo, and it not coincidentally happens to be the functionality the framework was designed to easily support. The real test of the system comes when you want to do something the designer did not anticipate, and you find out how flexible the system is and how sensible the designer's instincts are.

    With these environments I think time will tell, with most developers watching the few willing to take the risk of investing the time needed to learn the framework and how to customize it extensively.
  • Ruby on Rails is growing at an astounding rate right now, which is not at least due to the growing number of real-life applications that has been build upon it. Including:

    Basecamp [basecamphq.com] -- The original Rails application from which the framework was extracted. A hosted project management application that combines weblog, todo lists, milestones, file storage, and more to keep everyone on the same page in a project.

    43 Things [43things.com] -- The "What do you want to do with your life?" application that lets you enter the 43 t
  • It is impressive to produce that working (although spartan) website with a single line of code. But...

    Last time Ruby on Rails came up, someone mentioned this example [rubyonrails.com] showing off their object-relational mapping. I observed [slashdot.org] then that it makes way too many queries because the SQL it produces isn't very good. (And too many queries means a lot of slowness, especially when your database server and your webserver aren't on the same machine.)

    It's not as obvious here because all of the queries are behind the sce

    • The most recent release of Rails supposedly cleans up a lot of issues, including some with the SQL generation.

      It also implements caching at a variety of levels, to further speed things up. The most recent releases of rails are dramatically faster than prior.

    • If you find that the application is making too many SQL queries and is bogging down performance, then ActiveRecord (the database part of Rails) lets you create custom SQL queries.

      So what's the problem?
  • Anyone else find it strange that the author didn't use 3 of the products in "LAMP"?

    Didn't use Linux, used Windows,
    Didn't use Apache, used WEBrick,
    Didn't use PHP/Perl, used Ruby.

    Shouldn't this article be on ONWwmr.com?
  • by MarkWatson ( 189759 ) on Friday January 21, 2005 @01:39PM (#11434152) Homepage
    I played with Rails and liked it, but I am now trying to cut down on the number of programming languages that I use (trying hard to just use Java, Python, and Common Lisp) and even though it was fun working through a Ruby tutorial, I think that I am going to give Ruby a pass, at least for now.

    For Python, I have been experimenting with CherryPy [cherrypy.org] which is a fairly low level web application framework, but is easy to use for publishing web services using XML-RPC, generating dynamic HTML (it does not have a template language but works with a few Python HTML template packages), etc.

    Anyway, CherryPy "seems just about right" - light weight and easy to use - definitely does not have the capability of Rails though.

  • This seems nice and fast, but the sad fact is Ruby doesn't have the ISP support or userbase of the "P"'s.

    So, when will they create a competitor to this? Or have I missed it already . . .
  • That's a great under-the-hood framework. I want to draw client/server diagrams across both the presentation/logic and logic/data tiers, and compile my WWW/App/DB flowchart into HTML/Executable/SQL code.
  • Development time (Score:2, Informative)

    by cardmagic ( 224509 )

    I originally built Web Collaborator [webcollaborator.com] in 8,000 lines of PHP over a couple of months. In about 16 hours, I had completely rebuilt it from scratch in the Ruby on Rails framework with 1,000 lines of code.

    I have since created sites like The Conjuring Cabaret [rufy.com] and S5 Presents [s5presents.com], both with astonishing simplicity and rapid development. Rails gives me short-cuts for almost everything I ever want to do with web development.

  • by drew ( 2081 ) on Friday January 21, 2005 @03:51PM (#11435677) Homepage
    i've tried rails a little bit, and jsp before that, and wasn't particularly impressed with either. is there a reason all web frameworks require a weird directory structure? rails seems better then jsp because it doesn't require an arcane descriptor file, but it still requires you to use a funky directory structure, which means the structure of your application doesn't seem to correspond in any meaningful way with your web site structure.

    why can't someone build a decent framework that follows the simple "directories are directories and files are pages" model used by asp, php, cgi, etc.

    and what's with the database naming conventions? the author kind of brushes it off at the end with this statement: "Even if you have to use a legacy database that does not use the Rails naming conventions, you don't have to give up the productivity advantages of using Rails--there is still a way to tell Rails explicitly what table and column names to use." personally I would not use those conventions no matter what database i was using, nor would any decent database developer or administrator i have ever known.

    at any rate, at work i program in whatever language they tell me- currently asp+jscript, before that php. for personal projects, my current favorite is perl's HTML::Mason. all the benefits of php (and then some) without the awful language conventions.

"How to make a million dollars: First, get a million dollars." -- Steve Martin

Working...