-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection representor not using property constraints of representer #77
Comments
That collection document you're getting is because your collection representer is not used at all, it's Rails It looks as if the Can you add this, please? module LanderCollectionRepresenter
include Representable::JSON::Collection
def to_json
raise "hey, i am called!"
end
end |
Looks like the error was indeed raised.
def create_response(model)
render_method = "to_#{format}"
media_format = Mime[format]
# stuck on this line
Response.new(model.send(render_method, options), media_format)
end |
That's great, so Can you please convert class LanderRepresenter < Roar::Decorator
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia
property :name
property :location
link :self do
v1_lander_url self
end
end |
Thanks for the quick response! Just tried to make it a decorator. Same issue. I am on Rails 4.1.5 and Ruby 2.1.3 if that helps 😄 |
Is 2.1.3 already out? 😁 I'll have a look in a couple of hours, not sure what's going on. |
@apotonick I forgot to mention, my |
Hm, since you define it explicitely in What representable version? And what roar version? |
We are using
|
Update: confirmed this behavior on another Rails 4.1.5 app. |
@apotonick |
Turns out the issue disappeared when we namespaced our representers. |
** namespaced our representers AND used the decorator class pattern. |
Does the |
No it does not. |
+1 I got same issue here. |
I don't really know what to do here! This seems to be an autoloading/constant-referencing problem, and I still don't understand why Rails doesn't crash but uses the internal Do we have any way to provoke that problem in a minimal Rails app? |
After some digging trying to find the best way to respond_with a collection of
landers
... in my app I have:Is this the proper way to respond_with a collection? Rendering the LanderRepresenter works perfectly; however, when I render the collection, it spits out the entire object (without limiting the response to the property constraints on
:name, :location, :link
). i.e:The text was updated successfully, but these errors were encountered: