I want to change some value in one table in case of changing or
creating record in other. For example:
when somebody leave a comment to the post, i want to change count of
comments of this post using after_create hook.
How to access a post from comment's after_create hook?
class CreatePosts < Sequel::Migration
def up
create_table :posts do
primary_key :id
Text :data
MediumInt :comments_count
end
end
end
class CreateComments < Sequel::Migration
def up
create_table :comments do
primary_key :id
Text :data
foreign_key :post_id, :posts
end
end
end
class Post < Sequel::Model
one_to_many :comments
end
class Comment < Sequel::Model
many_to_one :post
end
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---