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
<p>
<b>OwnerName:</b>
<%= @image.imageable%>
</p>
*****
when i rendering the http://localhost:3000/images/1, the wrong message
as following:
*****
NameError in Images#show
Showing /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: <p>
19: <b>OwnerName:</b>
20: <%= @image.imageable%>
21:
22: </p>
23:
*********
Any one could help , thanks in advance!!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.