Re: Legacy join table with extra attributes and Rails 2.0

Brian Hogan
Thu, 21 Aug 2008 02:41:48 -0000

As far as I know, you just have to start using has_many :through and
refactor your code.  If I ever had a situation where I had to do this, I
would turn push_with_attributes into a plugin by extracting it from the
Rails 1.2.3 tag. Since I haven''t needed it yet, I haven''t done
it. It most
likely isn''t that hard to do but I haven''t looked.


On Fri, Aug 15, 2008 at 8:06 PM, RoRdeveloper
<rpuri@rhythmnewmedia.com>wrote:

>
> I am a fresh RoR developer and I am facing difficulty in getting a
> legacy join table (with extra attributes) to work with Rails 2.0.
> Please excuse
> me in case this is not the right forum for discussing this matter.
>
> My rails application works well with Rails 1.2.3. Following is the
> set-
> up:
>
> class Article
> has_and_belongs_to_many :users
> end
>
> class User
> has_and_belongs_to_many :articles
> end
>
> Legacy join table "articles_users" has the exepcted columns: (1)
> article_id (2) user_id, and an extra third column say, (3) more_info
>
> Following are my observations:
>
> (1) In my application, I use "push_with_attributes" method to
save
> records to the legacy join table. My understanding is that support for
> "push_with_attributes" in particular, and extra attrbutes in
habtm
> join tables, in general, is not present in Rails 2.0
>
> (2) I tried to modify my application using the Rails recommended
> approach of using "has_many :through" associations to realize
join
> table with extra attributes. However, in this case Rails 2.0 appears
> to complain that the join table does not have a primary id column.
>
> Is there a way to resolve this issue in Rails 2.0 framework without
> having to change the database table? Please let me know if I am
> missing something obvious.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---