Hi,
I’m following the Polymorphic Associations test, issue as following.
class Product < ActiveRecord::Base
has_many :images, :as=>:imageable
end
class User < ActiveRecord::Base
has_many :images, :as=>:imageable
end
class Image < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true
end
**migration:
class CreateImages < ActiveRecord::Migration
def self.up
create_table :images do |t|
t.integer :imageable_id
t.string :imageable_type
t.string :name
t.timestamps
end
end
def self.down
drop_table :images
end
end
**rending views/images/show.html.erb
OwnerName: <%= @image.imageable%>
***** when i rendering the http://localhost:3000/images/1, the wrong message as following: ***** NameError in Images#showShowing /home/orient/rails-app/temp1/app/views/images/show.html.erb
where line #20 raised:
wrong constant name user
Extracted source (around line #20):
17:
18:
19: OwnerName:
20: <%= @image.imageable%>
21:
22:
23:
Any one could help , thanks in advance!!