Forum: Ruby on Rails Re: Re: HABTM Duplicates?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A08294389f09fd2f509ff027540ddd75?d=identicon&s=25 unknown (Guest)
on 2006-06-12 18:02
(Received via mailing list)
Not too much going on in the code (I don't think). Several select boxes
in
the character view, which look somewhat like this:

<% regular_skills =
SkillCategory.find(:first, :conditions => "name = 'Regular'").skills %>


<select id="character_skill_ids" name="character[skill_ids][]">
<%= options_from_collection_for_select(regular_skills,
'id', 'name')
%>
</select>

Which is all being saved with the normal create
method in the characters_controller (no extra code there from me).

I'll
look into your has_many :through suggestion also. Thanks for looking.

Matt


--- rails@lists.rubyonrails.org wrote:

> > Is there perhaps an option
to have Rails write duplicates into the
> > table,
> > or am I looking
at the whole model incorrectly? Any advice would be
> > appreciated.
>

> That should work. Hard to say why it's not without seeing your code. But

> another approach would be to use a has_many :through association with
a
> count attribute in the join model. Then you wouldn't need to worry about

> counting multiple rows in the join table.
>
> --
> Josh Susser
>
http://blog.hasmanythrough.com
>
> --
> Posted via http://www.ruby-forum.com/.

> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
This topic is locked and can not be replied to.