Skip to content

Commit

Permalink
fix(models_controller): ActiveRecord 4.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
paulRbr committed Aug 22, 2014
1 parent a627e8c commit 61d581f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/yodatra/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ def nested_resources

unless parent_model.nil?
parent = parent_model.find params[:captures].second
resources = parent.send(involved.to_sym) unless parent.reflections[involved.to_sym].nil?
if parent.respond_to? :reflections
# This is AR 4.0.x compatibility
has_association = !parent.reflections[involved.to_sym].nil?
else
# This is AR 4.1.x compatibility
has_association = !parent._reflections[involved.to_sym].nil?
end
resources = parent.send(involved.to_sym) if has_association
end
resources
rescue ActiveRecord::RecordNotFound
Expand Down

0 comments on commit 61d581f

Please sign in to comment.