I havent played with polymorphic associations yet, but is there some reason this wont work?<br>
<br>
class Comment &lt;ActiveRecord::Base<br>

&nbsp; belongs_to :commentable, :polymorphic =&gt; true<br>

&nbsp; belongs_to :user<br>

end<br>
<br>
&gt;That's the problem with rails' strict naming conventions... if you<br>
&gt;want to create more than one link between the same two tables, you're<br>
&gt;a bit stuck. Hope this helps.<br>
<br>
That's a common misconception. The naming is just a convention (or, an easy default)-- it can always be configured differently.<br>

<br>
class Comment &lt;ActiveRecord::Base<br>
&nbsp; belongs_to :commentable, :polymorphic =&gt; true<br>
&nbsp; belongs_to :author, :class_name =&gt; &quot;User&quot;, :foreign_key =&gt; &quot;user_id&quot;<br>
end<br>
<br>
Would work the same as the above.<br>
<br>
Maurice<br><br><div><span class="gmail_quote">On 3/31/06, <b class="gmail_sendername"><a href="mailto:njmacinnes@gmail.com">njmacinnes@gmail.com</a></b> &lt;<a href="mailto:njmacinnes@gmail.com">njmacinnes@gmail.com</a>&gt; wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Maybe if you have an intermediate table, which links one-to-one to the<br>users (maybe called &quot;commentor&quot;), then each comment can link to that?
<br>It's a little clunky, but less so than any alternative I can think so.<br>That's the problem with rails' strict naming conventions... if you<br>
want to create more than one link between the same two tables, you're<br>
a bit stuck. Hope this helps.<br>
-Nathan<br><br>On 31/03/06, Eric Schultz &lt;<a href="mailto:hammy@charter.net">hammy@charter.net</a>&gt; wrote:<br>&gt; I'm playing around with RoR and I'm having trouble figuring out how to<br>&gt; describe a certain relationship. I'm building a social networking site
<br>&gt; where you have users who can comment on other users, photos, videos, and<br>&gt; blogs. I've figured out how to have a comment belong to a user or media<br>&gt; item through a polymorphic relationships but I dont' know how to have
<br>&gt; the comment also be &quot;owned&quot; by the user who made the comment. I've<br>&gt; included some code to help with the description:<br>&gt;<br>&gt; #User class<br>&gt; class User &lt; ActiveRecord::Base<br>&gt; has_many :photos
<br>&gt; has_many :blogs<br>&gt; ...<br>&gt; end<br>&gt;<br>&gt; #photo (also blog and video are similar)<br>&gt; class Photo &lt; ActiveRecord::Base<br>&gt; belongs_to :user<br>&gt; has_many :comments, :as =&gt; :commentable
<br>&gt; end<br>&gt;<br>&gt; #comment class<br>&gt; class Comment &lt; ActiveRecord::Base<br>&gt; belongs_to :commentable, :polymorphic =&gt; true<br>&gt; end<br>&gt;<br>&gt; #comment table includes the following fields:<br>
&gt;<br>&gt; id<br>&gt; content &lt;--- the actual comment text<br>&gt; user_id &lt;--- the user who made the comment<br>&gt; commentable_id<br>&gt; commentable_type<br>&gt;<br>&gt;<br>&gt; I've thought this over for 2 days and I still can't seem to figure out a
<br>&gt; way to describe what I want to describe... Does anyone have any ideas or<br>&gt; suggestions on how to do this?<br>&gt;<br>&gt; --<br>&gt; Posted via <a href="http://www.ruby-forum.com/">http://www.ruby-forum.com/
</a>.<br>&gt; _______________________________________________<br>&gt; Rails mailing list<br>&gt; <a href="mailto:Rails@lists.rubyonrails.org">Rails@lists.rubyonrails.org</a><br>&gt; <a href="http://lists.rubyonrails.org/mailman/listinfo/rails">
http://lists.rubyonrails.org/mailman/listinfo/rails</a><br>&gt;<br>_______________________________________________<br>Rails mailing list<br><a href="mailto:Rails@lists.rubyonrails.org">Rails@lists.rubyonrails.org</a><br><a href="http://lists.rubyonrails.org/mailman/listinfo/rails">
http://lists.rubyonrails.org/mailman/listinfo/rails</a><br></blockquote></div><br>