Hi there! I'm trying to implement a new feature, called gadgets. Let me explain it shortly: gadgets are small icons like a candle, a heart, a flower, etc. Users can send these gadgets to each other and to certain events. E.g. I have an event called "midnight party", users should have the opportunity to add little beercups as gadgets to this event.
This feature almost works fine. But I have one problem: I have to know which user has added the gadget. This is how I implemented the gadget- feature: I created a model called "Gadget". This model helds all available gadgets users can add to each other or to an event. I created a model called "GadgetLink". This is for the association between an model and the gadget. I associated the user model with GadgetLink and Gadget. In code this would like this: class Gadget < ActiveRecord::Base has_many :gadget_links end class GadgetLink < ActiveRecord::Base belongs_to :gadget belongs_to :gadgable, :polymorphic => true end class User < ActiveRecord::Base has_many :gadget_links, :as => :gadgable has_many :gadgets, :through => :gadget_links end This works fine at all. I can call @user.gadgets << @gadget in a controller an add so an gadget to an user. But now I want to extend this so that I know which user added the gadget. First I tried to add belongs_to :user in my GadgetLink class, but everytime a new record was made to the database the column user_id still gets NULL. Because I'm very new to ruby and rails I don't know exactly how I can realize this. Can anybody help me? Thanks a lot! P.S.: Maybe I will try to create a plugin of this if anyone interested... just let me know --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CommunityEngine" group. To post to this group, send email to communityengine@googlegroups.com To unsubscribe from this group, send email to communityengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/communityengine?hl=en -~----------~----~----~----~------~----~------~--~---