You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks, thanks for your hard work on this gem and the other Ruby client libraries!
I'm working with a Rails 4.2.11.1 project and the latest version of contentful_rails (0.4.2), which bundles contentful_model (1.0.1) and contentful (2.12.0). When I retrieve a collection of entries, I get a Contentful::Array object returned; within Rails, I'd like to be able to pass this object to the render method in my view to render a view template for each element of the array. To this end, my Contentful model has extend ActiveModel::Naming and include ActiveModel::Conversion implemented so that Rails knows how to find an associated view template for a given Contentful model; where I'm getting stuck is the initial render call with the Contentful::Array as an argument. Rails tries to figure out if the argument is a single object or a collection, using respond_to?(:to_ary) as a test (source).
Since Contentful::Array does not implement to_ary, Rails thinks it is a singular object, but since Contentful::Array does not implement to_partial_path, I get the usual error: '<Contentful::Array total=3 skip=0 limit=100>' is not an ActiveModel-compatible object. It must implement :to_partial_path.
Let me know if there's any further details I can provide about my use case :)
The text was updated successfully, but these errors were encountered:
Hi folks, thanks for your hard work on this gem and the other Ruby client libraries!
I'm working with a Rails 4.2.11.1 project and the latest version of
contentful_rails
(0.4.2), which bundlescontentful_model
(1.0.1) andcontentful
(2.12.0). When I retrieve a collection of entries, I get aContentful::Array
object returned; within Rails, I'd like to be able to pass this object to therender
method in my view to render a view template for each element of the array. To this end, my Contentful model hasextend ActiveModel::Naming
andinclude ActiveModel::Conversion
implemented so that Rails knows how to find an associated view template for a given Contentful model; where I'm getting stuck is the initialrender
call with theContentful::Array
as an argument. Rails tries to figure out if the argument is a single object or a collection, usingrespond_to?(:to_ary)
as a test (source).Since
Contentful::Array
does not implementto_ary
, Rails thinks it is a singular object, but sinceContentful::Array
does not implementto_partial_path
, I get the usual error:'<Contentful::Array total=3 skip=0 limit=100>' is not an ActiveModel-compatible object. It must implement :to_partial_path.
Let me know if there's any further details I can provide about my use case :)
The text was updated successfully, but these errors were encountered: