Skip to content

Commit

Permalink
Added #parent and #parent_type to BelongsToHelper.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel authored and josevalim committed Dec 22, 2009
1 parent 2ea5a64 commit e2931cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/inherited_resources/belongs_to_helpers.rb
Expand Up @@ -56,6 +56,14 @@ module BelongsToHelpers
def parent?
true
end

def parent
@parent ||= association_chain[-1]
end

def parent_type
parent.class.name.underscore.to_sym
end

private

Expand Down

0 comments on commit e2931cb

Please sign in to comment.