Created
January 6, 2009 04:45
-
-
Save agibralter/43673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < ActiveRecord::Base | |
has_many :comments | |
attr_accessor :current_comment | |
end | |
class Comment < ActiveRecord::Base | |
module Foo | |
def and_set_current_comment | |
self.current_comment = proxy_owner | |
self | |
end | |
end | |
belongs_to :post, :extend => Foo | |
end | |
# in code, lets say post 12 has 10 comments | |
@post = Post.find(12) | |
@comment = @post.comments.first | |
@post = @comment.post.and_set_current_comment | |
@post.current_comment = @comment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment