the content_entries API returns always a flat list of entries + fix a bug about cycling dependencies when the content_type has a field named source
This commit is contained in:
parent
ac823aac66
commit
37042eaa03
@ -5,7 +5,7 @@ module Locomotive
|
||||
before_filter :set_content_type
|
||||
|
||||
def index
|
||||
@content_entries = @content_type.list_or_group_entries
|
||||
@content_entries = @content_type.ordered_entries
|
||||
respond_with @content_entries
|
||||
end
|
||||
|
||||
|
@ -36,8 +36,11 @@ module Locomotive
|
||||
super + self.filtered_custom_fields_methods + default_list
|
||||
end
|
||||
|
||||
def method_missing(meth, *arguments, &block)
|
||||
if self.source.custom_fields_methods.include?(meth.to_s)
|
||||
def as_json(methods = nil)
|
||||
methods ||= self.included_methods
|
||||
{}.tap do |hash|
|
||||
methods.each do |meth|
|
||||
hash[meth]= (if self.source.custom_fields_methods.include?(meth.to_s)
|
||||
if self.source.is_a_custom_field_many_relationship?(meth.to_s)
|
||||
# go deeper
|
||||
self.source.send(meth).map { |entry| entry.to_presenter(:depth => self.depth + 1) }
|
||||
@ -45,7 +48,9 @@ module Locomotive
|
||||
self.source.send(meth) rescue nil
|
||||
end
|
||||
else
|
||||
super
|
||||
self.send(meth.to_sym) rescue nil
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user