Question

I installed this with railsinstaller:

C:\Sites>ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

C:\Sites>rails -v
Rails 3.0.3

C:\Sites>gem -v
1.3.7

I used railinstaller to install Ruby on Rails. At first I installed the 3.0.0 version with the updated version of Ruby, and Rails, however, as I want to use some Rails 3.1.0 code, I uninstalled v 3.0.0 and installed others, but the result is terrible. I cannot even run the rails server so I tried again and only this version works.

I am running the example in Chapter 6 of "Agile Web Development":

  1. Create a Rails application using :rails new depot
  2. Generate the scaffold using:

    rails generate scaffold Product\
    title:string description:text image_url:string price:decima
    
  3. Change create_product.rb by adding the length of decimal.

I got everything ready, but when I run rake db:migrate, I get this:

C:\Sites\depot>rake db:migrate
(in C:/Sites/depot)
==  CreateProducts: migrating =================================================
-- create_table(:products)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `ext' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0
x599f4c0>

(See full trace by running task with --trace)

Here is the full trace:

C:\Sites\depot>rake db:migrate --trace
(in C:/Sites/depot)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateProducts: migrating =================================================
-- create_table(:products)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `ext' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x4c4d618>
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:326:in `method_missing'
C:/Sites/depot/db/migrate/20140108105456_create_products.rb:5:in `up_without_benchmarks'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:157:in `create_table'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:383:in `send'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:383:in `method_missing'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:359:in `say_with_time'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/benchmark.rb:293:in `measure'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:359:in `say_with_time'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:379:in `method_missing'
C:/Sites/depot/db/migrate/20140108105456_create_products.rb:3:in `up_without_benchmarks'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:in `send'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:in `migrate'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/benchmark.rb:293:in `measure'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:in `migrate'
F:0:in `__send__'
F:0:in `migrate'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:537:in `migrate'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:611:in `call'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:611:in `ddl_transaction'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in `transaction'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:611:in `ddl_transaction'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:536:in `migrate'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:523:in `each'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:523:in `migrate'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:in `up'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:415:in `migrate'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:142
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/monitor.rb:242:in `synchronize'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
F:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
F:/RailsInstaller/Ruby1.8.7/bin/rake:19:in `load'
F:/RailsInstaller/Ruby1.8.7/bin/rake:19

I am quite new to Ruby on Rails, and do not how to solve this bug. How can I solve this? Many thanks!

Was it helpful?

Solution

I've gone through all the steps provided and it seems that you have a syntax error there. Here's the migration code:

class CreateProducts < ActiveRecord::Migration
 def self.up
  create_table :products do |t|
   t.string :title
   t.text :description
   t.string :image_url
   t.decimal :price

   t.timestamps
  end

 end

 def self.down
  drop_table :products
 end
end

On line 5 for stored description, it seems you've added a space or removed t.t.

Take a look at the line with this code:

t.text :description

OTHER TIPS

It looks like you have an error in this file:

C:/Sites/depot/db/migrate/20140108105456_create_products.rb:5

The error messages tells you what's wrong:

An error has occurred, this and all later migrations canceled:

undefined method `ext'   

You have the word "ext" in the "20140108105456_create_products" file. And, it is not a method that this file knows.

If you post the migration file in you question, I'll tell how to fix it .

I had a similar error "undefined method `content' for..."

Somehow my migration file had the following:

t.content :text

instead of

t.text :content

Looks like the tin man is right, probably you have t.ext :description instead of t.text.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top