Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Cookin' with Ruby on Rails - May
Subject:   Migration Error on Linux
Date:   2007-07-10 11:41:25
From:   waylonflinn
Howdy,


I finished the article series ending at:


http://www.onlamp.com/pub/a/onlamp/2007/01/05/revisiting-ruby-on-rails-revisited-2.html?page=4


and followed the link over here. Everything seemed to go fine until I got to page 4 and the db:migrate command which runs AddContributorName (file shown here: http://www.oreillynet.com/ruby/2007/05/17/graphics/figure018_large.gif). It gave me the following error:


"You have a nil object when you didn't expect it!"


After a comparison with http://www.oreillynet.com/ruby/2007/05/17/graphics/figure019_large.gif I changed "string" to :string and got the following error:


"Mysql:Error: Table 'rollingrails_development.Recipes' doesn't exist:[...]"


I then changed 'Recipes' to 'recipes' in the add_column function. This produced the results expected.


Thanks for the excellent series,
Waylon

Full Threads Oldest First

Showing messages 1 through 4 of 4.

  • Migration Error on Linux
    2007-07-11 06:36:36  Bill Walton | [View]

    Hi Waylon,

    Sorry you had a problem, but thanks much for making the time to let me know. If you get a chance, it would be great to know what Linux distro, version of Rails, etc. you're using. I'd like to investigate / understand this better. I'm working in Windows and I'm guessing there must be some difference between it and your Linux distro that's causing this. Maybe there's a way to avoid it. Sometime in the next few weeks I'm going to go back and redo the images to make them small enough that they don't require the "click to enlarge" button and, at the same time, I'll have an opportunity to make some minor changes.

    Thanks again.
    Bill
    • Migration Error on Linux
      2007-07-29 03:00:52  Geldart [View]

      Bill:

      Exactly the same problem here (Ubuntu 7.04, Ruby 1.8.5, Rails 1.2.1). Fix needed seems to be two things:

      • "recipes" not "Recipes"

      • :string no "string"


        • i.e.:

          class AddContributorName < ActiveRecord::Migration
          def self.up
          add_column("recipes", "contributor_name", :string, :default => "Unknown")
          end

          def self.down
          remove_column("recipes", "contributor_name")
          end
          end
    • Migration Error on Linux
      2007-07-22 10:23:19  DaveMatuszek [View]

      I had the same problem using InstantRails 1.7 with
      Ruby 1.8.6 and Rails 1.2.3. Capitalization of "Recipes" doesn't seem to be important, but "string" must be :string.

      The error (evaluating nil.[]) occurs in
      .../schema_statements.rb:272:in 'type_to_sql'
      the line reads:
      limit ||= native[:limit]
      I also found
      native = native_database_types[type]
      and
      def native_database_types
      {}
      end
      and no additions to this hash. My Ruby isn't yet
      good enough to figure out why this can ever work....
      • Migration Error
        2007-08-14 11:25:56  ezosoro [View]

        It took looking at the screen shot of the command prompt window before I got this to work correctly, as it shows something totally different then the screen shot of the "002_add_contributor_name" file.

        If you use this for the "add_column" line it should work correctly...

        add_column("Recipes", "contributor_name", :string, {:default => "Unknown"})

        It was missing the brackets around the default value and string needs a colon and no quotations afterwards. Hope it helps everyone out ;).