
Uninitialized constant using polymorphic association
Reported by Rob | January 21st, 2009 @ 10:14 AM
Using a polymorphic association, I get an "uninitialized constant" error when I click on an order_by_link. For a test case, I set up the following example, where the regular association "post" works as expected, while the polymorphic association "resource" returns "uninitialized constant CatalogEntry::Resource" when clicking on their respective links. Using version 1.6.2.
I am a Rails noobie, my apologies if I'm missing something obvious, and thanks for a very useful plugin.
class CatalogEntry < ActiveRecord::Base
belongs_to :resource, :polymorphic => true
belongs_to :post
end
class Article < ActiveRecord::Base
has_one :catalog_entry, :as => :resource
end
class Post < ActiveRecord::Base
has_one :catalog_entry
end
create_table :catalog_entries
t.string :name
t.integer :resource_id
t.string :resource_type
t.integer :post_id
end
create_table :articles
t.text :content
end
create_table :posts
t.text :content
end
class Jquery::CatalogEntriesController < ApplicationController
def index
@search = CatalogEntry.new_search(params[:search])
@cats, @cats_count = @search.all, @search.count
end
end
<tr>
<th><%= order_by_link :id %></th>
<th><%= order_by_link :resource => :content %></th>
<th><%= order_by_link :post => :content %></th>
</tr>
<% @cats.each do |cat| %>
<tr>
<td><%= cat.id %></td>
<td><%= cat.resource.content%></td>
<td><%= cat.foo.content%></td>
</tr>
Comments and changes to this ticket
-
-
man citylion February 28th, 2022 @ 02:16 AM
ufa Is the number 1 most popular online gambling website
-
-
-
USAJumpgrowth March 19th, 2022 @ 11:27 AM
wonderful discussion going on regarding this topic its is worth of sharing, eventually thanks for sharing.
Nyc blog go for which is better angularjs vs reactjs,.
difference between angular and react,. -
man citylion March 20th, 2022 @ 03:05 AM
ufa Lots of games, including many online slots betting games
-
mtsejin (at gmail) April 4th, 2022 @ 10:28 PM
I'm going to see some good stuff. I will visit you often in the future. Please also visit our blog.먹튀검증
-
neetting April 19th, 2022 @ 05:29 AM
If you are interested in online gambling, look no further, start here. at 123over only.[url=https://www.123over.app/2022/01/28/recommend-slot-big-win/] 123over [/url]
-
-
-
yolo April 20th, 2022 @ 07:04 AM
วิธีคิดบอลสเต็ปMany good promotions that look for both old and new customers.
-
yolo April 20th, 2022 @ 07:15 AM
2-2.5 Full casino, baccarat, slots, fish shooting games and other games
-
-
football ball May 9th, 2022 @ 01:46 AM
Slots minutes are easy to break. Come soon Play.123 over 123over
-
football ball May 12th, 2022 @ 11:18 PM
I want to play this website to give away It's easy to break like this.123 over Slots are easy to break
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Provides common named scopes and object based searching.