Women in Technology

Hear us Roar

  Rolling with Ruby on Rails
Subject:   Not working as advertised
Date:   2005-01-29 19:52:32
From:   pyellman
I followed this tutorial closely, first on Linux (Debian - as closely as possible) and then on MS Windows to confirm. Some things worked as advertised, with one major snafu: links were not generated correctly.

For example, when at location http://localhost:3000/Recipe/list, the link titled "New Recipe" points to http://localhost:3000/Recipe/list, and the link titled "Show" points to http://localhost:3000/Recipe/list/3 (should point to http://localhost:3000/Recipe/show/3).

Similarly, when at the index ("Recipe"), "Show" points only to http://localhost:3000/Recipe/5, and "New recipe" points only to http://localhost:3000/Recipe. Also, the action for adding a new recipe does not actually point to new.

I can do a show by manually entering in http://localhost:3000/Recipe/show/3. I can view (list) recipes in the database. Also, at some point early in following the tutorial, I was able to add 2 records.

Anybody else have a similar experience?

Peter Yellman

Full Threads Oldest First

Showing messages 1 through 13 of 13.

  • Curt Hibbs photo Not working as advertised
    2005-01-30 00:15:59  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

    I think this is my fault. About five days after this article was published, a new version of Rails was released, that changed some of the URLs that I had used in this article (all URLs containing "MyTest" changed to "My_Test").

    Rather than change the URLs in this article I told people to uninstall Rails 0.9.5 and install 0.9.4 and I change this article to spcify that Rails 0.9.4 be installed.. I was hoping that using a specific version of Rails would prevent future Rails releases from breaking this tutorial.

    Unfortunately, doing this causes the problem you are having. So, I've asked the ONLamp.com editor to revert back to installing the latest version of Rails and change the URLs containing "MyTest" to use "My_Test".

    I profusely apologize for causing you all this frustration, and I suggest that you start over with a fresh installation of Ruby, and just install Rails using the command "gem install rails --remote", then use "My_Test" in the URLs wherever you see "MyTest".

    Also note, I've seen reports that on linux systems you may have to use all lowercase in the URLs, i.e., "my_test" (which should work on Windows, too).
    • Not working as advertised
      2005-01-30 08:52:18  pyellman [View]

      Hmm, while I suspect something along the lines of what you say, that does not solve my problem. I read the comments regarding the rails 0.9.4 vs 0.9.5 issue well before I began acually began working through the tutorial. In fact, I even installed 0.9.5 deliberately just to see the issue for myself, then uninstalled, installed 0.9.4, and began the tutorial again from the very beginning; (actually, I did this more than once, and tried on both Linux and Windows).

      So, I have no issues with the MyTest v. MyTest type urls -- I get that part; take another look at my first post and you will see that my problem is that the scaffold-generated urls in the recipe app (using rails 0.9.4 and Ruby 1.8.2 simply do not even include the action/method at the end of the url. So, for example, the url labled "New recipe" on the list page simply leads back to the list page itself, with a record number appended. As I mentioned, I can type in the url , e.g., /recipe/show/2, and it displays fine.

      Peter Yellman
      • Curt Hibbs photo Not working as advertised
        2005-01-30 09:26:50  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

        Part of the problem (at least the part I understand) has to do with the fact that the RubyGems package named "rails" is composed of some glue code that binds together three other, independent RubyGems packages named "activerecord", "actionpack" and "actionmailer.

        And, for example, the rails-0.9.4 package says it depends on the packages activerecord-1.5.0 or greater, actionspack-1.3.0 or greater, and actionmailer-0.6.0 or greater. Rails-0.9.5 uses more recent versions of all three packages. The problem here is with the "or greater" part.

        When you "gem uninstall rails" it only removes the rails package, and not the others. When you say "gem install rails -v 0.9.4" it happily installs rails-0.9.4, but keeps using the more recent versions of the other packages because the "or greater" part of the dependency tells RubyGems those packages work fine rails-0.9.4. The problem is that they don't, and cause the weird URLs that you are seeing. This has got to be an unforseen bug in Rails' gemspec, and I need to post a bug report for this.

        To make matters worse, you can't even go back to rails-0.9.4 by trying to install the desired packages manually. I tried to do this last night:

        gem install activerecord -v 1.5.0
        gem install actionpack -v 1.3.0
        gem install actionmailer -v 0.6.0
        gem install rails -v 0.9.4

        When installing rails-0.9.4 RubyGems should notice that all the other needed packages are already installed and just install the rails package. Unfortunately, it does install rails-0.9.4 and then proceeds to install rails-0.9.5 and the latest version of all the other packages. This has got to be a bug in the RubyGems package manager, and I will report this as well.

        But, the bottom line is that there is currently no way to correctly install anything but the latest version of rails, and the uninstall/reinstall instructions that I gave earlier not only don't work, but also cause bizarre strangeness due to these unintended incompatibilities.

        I would recommens that you wipe out everything and reinstall from a clean slate, stick with rails-0.9.5 and do not attempt to install an older version.
        • Not working as advertised
          2005-01-30 10:42:56  pyellman [View]

          Ahh yes -- a tangle web. Thanks for the input. That explains why my "clean slate" Windows install also suffered the problem; gem must have installed the newer versions of activerecord, actionpack, etc.

          Oh well, it's beta and I've learned plenty. I'll give it a go with rails 0.9.5.

          Peter Yellman
          • Curt Hibbs photo Not working as advertised
            2005-01-30 17:01:38  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

            I'm sorry you're having so much trouble... after all, the whole point is that this is supposed to be easy.

            Perhaps you also need to start the cookbook application with a clean slate, too. In other words, not that you've got a clean rails 0.9.5 installed use that to create a new cookbook web app, and then proceed forward with that.
            • Not working as advertised
              2005-02-01 16:30:57  pyellman [View]

              Ok, it works now, with the latest.

              You were on to something with your comment "Also note, I've seen reports that on linux systems you may have to use all lowercase in the URLs, i.e., "my_test" (which should work on Windows, too)."

              After clean reinstall, always using lowercase urls generates links correctly for the Recipes application. Using the uppercase version (e.g., /Recipe/) _sort of_ works. The discussion of the MyTest vs. My_Test url took me on the wrong track of capitalizing the urls are per the naming of the model/controller, especially since My_Test (or MyTest) works fine.

              IMO, this is a bug. It should be either or, not "works one way, sort of works the other way". It raises obvious questions: (1) Why ? (2) Will this bite me in other ways, cost me more time down the line with unexpected behavior? I suppose the short answer is "always use lowercase urls". This definitely needs to be emphasized to Unix/Linux users, though, who might interpret simply "case matters" in a different way.

              Peter Yellman
            • Not working as advertised
              2005-02-01 02:18:19  coreman [View]

              Well, it just worked for me. I luckily installed Rails and got the newest versions of everything.

              Now, will you add stuff so that perhaps us database snobs can use Postgres instead of MySQL?

              And maybe you could post how to migrate this app to run under Apache (and the configurations for Apache to work with Ruby via FastCGI)?

              I find the config info on ruby-central/rubygarden/whatnot for using Ruby with Apache a bit confusing. I'm only vaguely familiar with editing http.conf and .htaccess, so when I see bits of config info, I'm not sure where it really should go into the one walkthru for this.

              • Curt Hibbs photo Not working as advertised
                2005-02-01 03:36:50  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

                The Ruby on Rails site has some info on this in the Howto section (click on "Documentation", then click on "Howto"). In particular, these two pages might be what you want:
                • Not working as advertised
                  2006-11-07 05:24:27  rrcjab [View]

                  Update - with Apache 2.x you want to use FCGI, *NOT* FastCGI. Again, be careful with documentation related to versions you may not be using.
                  • Curt Hibbs photo Not working as advertised
                    2006-11-07 05:54:41  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

                    FastCGI is no longer considered the preferred way to deploy Rails apps. The trend, instead, is to use Mongrel to serve up the rails app and mod_proxy to that from Apache. You can find Mongrel here:


            • Not working as advertised
              2005-01-30 20:42:53  pyellman [View]

              Yes, of course I always recreate the cookbook application -- it's just a couple lines of typing. In fact, I can now run through the whole tutorial in about 10 minutes flat!

              I don't recreate the database, though (my wife suggested reformatting the hard drive). As I said, I can list just fine, and perform all the other actions -- show, add, delete -- by doctoring the links.

              I'll try another example from the rails site. I want it to work!

              Peter Yellman
          • Not working as advertised
            2005-01-30 15:05:26  pyellman [View]

            I tried it will all the latest, from scratch:

            # gem list --local

            *** LOCAL GEMS ***

            actionmailer (0.6.1)
            Service layer for easy email delivery and testing.

            actionpack (1.4.0)
            Web-flow and rendering framework putting the VC in MVC.

            activerecord (1.6.0)
            Implements the ActiveRecord pattern for ORM.

            rails (0.9.5)
            Web-application framework with template engine, control-flow layer,
            and ORM.

            rake (0.4.15)
            Ruby based make-like utility.

            sources (0.0.1)
            This package provides download sources for remote gem installation

            Still the same problem -- actions not appended to urls. Can do everything by typing in the url, including "create" by saving the "new" page and modifying the post target to point to "create".

            Bummer. Oh well.
      • Not working as advertised
        2005-01-30 08:54:34  pyellman [View]

        So, for example, the url labled "New recipe" on the list page simply leads back to the list page itself, with a record number appended.

        Should read simply:
        So, for example, the url labled "New recipe" on the list page simply leads back to the list page itself.

        The record number of course gets appened to "Show" urls, but the show action does not.

        Peter Yellman