Brian H. wrote:
Cameron:
I have already taken a second look at my code, thanks.
Sorry, didn’t mean to sound condescending, We’re trying to help you,
please
keep that in mind. I wanted to assure you that there’s nothing wrong
with
the book. The problem you’re having is in your code, or more
specifically,
in your database.
As you already are probably aware:
img_url does not equal image_url.
Rails auto-generates methods in models based on your table definitions.
Since you had no column in your database table called ‘image_url’, you
were
getting that NoMethodError error.
For future reference, you should avoid using ALTER TABLE / CREATE TABLE
statements if you are using Migrations. You can get into trouble there.
Migrations issue all of the alter / create statements for you. You
really
need to choose between the two methods (migration vs managing your own
schema). They don’t mix well 
I hope everything works out for you. Remember, we’re a helpful bunch, so
keep the questions coming.
Hi Brian and Conrad,
Your help is much appreciated. The book came highly recommended so I
need to persevere. Perhaps you can see my error. There is no doubt I’m
learning more by dealing with these errors :). Best, Julian
I’ve followed the suggestions above:
1)checked the image_url field
2)Rolled back the migration
3) Called the Rake db:migrate again
4) Still getting
rake abort
undefined method `image_URL’ for #Product:0x3d98368
and got the following results:
mysql> use depot_development
Database changed
mysql> show tables;
±----------------------------+
| Tables_in_depot_development |
±----------------------------+
| products |
| schema_info |
±----------------------------+
2 rows in set (0.00 sec)
mysql> desc products;
±------------±-------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±------------±-------------±-----±----±--------±---------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(255) | YES | | NULL | |
| description | text | YES | | NULL | |
| image_url | varchar(255) | YES | | NULL | |
| price | decimal(8,2) | YES | | 0.00 | |
±------------±-------------±-----±----±--------±----------
-database field image_url is OK
C:>cd work
C:\work> cd depot
C:\work\depot> rake db:migrate VERSION=0
(in C:/work/depot)
== AddPrice: reverting
– remove_column(:products, :price)
-> 0.5000s
== AddPrice: reverted (0.5000s)
== CreateProducts: reverting
– drop_table(:products)
-> 0.0620s
== CreateProducts: reverted (0.0620s)
C:\work\depot> cat 001_create_products.rb
cat: 001_create_products.rb: No such file or directory
C:\work\depot> rake db:migrate
(in C:/work/depot)
== CreateProducts: migrating
– create_table(:products)
-> 0.1880s
== CreateProducts: migrated (0.1880s)
== AddPrice: migrating
– add_column(:products, :price, :decimal, {:precision=>8, :scale=>2,
:default=>
0})
-> 0.2660s
== AddPrice: migrated (0.2660s)
== AddTestData: migrating
rake aborted!
undefined method `image_URL’ for #Product:0x3d98368
(See full trace by running task with --trace)
C:\work\depot>
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.column :title, :string
t.column :description, :text
t.column :image_url, :string
end
end
def self.down
drop_table :products
end
end