The previous code fails when creating new blog this works

def tagging=(tagging)
    Tag.delete_all "technology_id not in (" + tagging.to_s + ") and
blog_id = " +self.id.to_s unless self.new_record?
    tagging.each do |tag|
      tags.build(:technology_id => tag) unless tags.any?{|t|
t.technology_id.to_i == tag.to_i}
    end
  #  Tag.delete_all "technology_id not in (" + tagging.to_s + ") and
blog_id = " +self.id.to_s unless self.new_record?
  #  tagging.each do |tag|
  #    self.tags.create(:technology_id => tag) unless tags.any?{|t|
t.technology_id.to_i == tag.to_i}
  #  end
end

It seems php but it works

On Oct 8, 6:00 pm, RoR_Nb <[EMAIL PROTECTED]> wrote:
> Lovely
>
> This might be a php solution but it works:
>
> def tagging=(tagging)
>     Tag.delete_all "technology_id not in (" + tagging.to_s + ") and
> blog_id = " +self.id.to_s
>     tagging.each do |tag|
>       self.tags.create(:technology_id => tag) unless tags.any?{|t|
> t.technology_id.to_i == tag.to_i}
>     end
>   end
>
> On Oct 7, 2:33 pm, RoR_Nb <[EMAIL PROTECTED]> wrote:
>
> > It did remove the mysql error thanks a lot guys.
> > but there's still a problem, and what happens is
> > that if i have 2 tags selected and then i unchecked 1 then it deletes
> > both,
> > maybe it has to do with the code. but i guess it's my login what's not
> > working,
> > is that correct?.
>
> > I'll work on that and if i find a solution i'll post it here for
> > future other people to see it.
>
> > On Oct 7, 3:33 am, Frederick Cheung <[EMAIL PROTECTED]>
> > wrote:
>
> > > On 6 Oct 2008, at 07:43, RoR_Nb wrote:
>
> > > > I know i don't have an id for the join table
>
> > > With has_many :through, the join table is a model in its own right and  
> > > needs a promary key
>
> > > Fred
>
> > > > class CreateTags < ActiveRecord::Migration
> > > >  def self.up
> > > >    create_table :tags, :id => false do |t|
> > > >      t.integer :blog_id
> > > >      t.integer :technology_id
> > > > ......
> > > >  end
> > > > end
>
> > > > How can i solve this problem?
> > > > thanks in advanced
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to