On Jan 12, 5:45 pm, Macario Ortega <[email protected]> wrote:
> Hi, I wan't to do something with a model after it has been saved, i.e.
> associate it with a list of tags after the model is saved but by then
> I loose my instance variables, this is the only non obvious for me
> behavior I found so far with sequel, I would not expect this to
> happen.
>
>   class Cause < Sequel::Model
>     many_to_many  :tags, :right_key => :tag_name
>
>     def tags= tags
>       @tag_names = tags.split(',').map(&:strip)
>     end
>
>     def after_update
>       @tag_names # => nil
>       super
>     end
>   end

Are you calling tags= on the same model instance before calling save/
update?  If not, that's probably the issue.  Also, you don't appear to
be persisting the tags, which raises a red flag to me.

Jeremy

>
> So the way for associating on creation would be outside the model?
>
> Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-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/sequel-talk?hl=en.

Reply via email to