
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 October 19th, 2021 @ 06:32 AM
บาคาร่าแตกง่าย you can enjoy with gambling games in this website. made your relax and get money.
-
-
789heng November 5th, 2021 @ 10:19 PM
" The best online casino sites in Thailandat 789heng only. สล็อต"""
-
eleeito November 29th, 2021 @ 05:11 AM
Avast Cleanup Premium Crack is an all-in-one tool that improves the performance of your PC and frees up disk space. Its modern interface and three-part feature set make it a powerful software tool. By securing your computer and keeping out malware and spyware, Avast Cleanup Premium can make your computer faster and more secure. It can also boost your system's speed and prevent errors.
-
man citylion November 29th, 2021 @ 08:04 AM
ufa
Online casino betting games That responds to the needs of the gambler fully. -
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.