Skip to content
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

Can't use child alias with conditional #395

Open
jfeust opened this issue Jan 28, 2013 · 1 comment
Open

Can't use child alias with conditional #395

jfeust opened this issue Jan 28, 2013 · 1 comment

Comments

@jfeust
Copy link

jfeust commented Jan 28, 2013

The following works as it should with the conditional:

collection @publish_times
child(:task, :if => lambda { |publish_time| publish_time.task_id.present? }) do
    extends "api/tasks/task"
end

But as soon as I try to alias the child object it throws an error:

# remove the alias (:todo) or the conditional (:if) and this works
collection @publish_times
child(:task => :todo, :if => lambda { |publish_time| publish_time.task_id.present? }) do
    extends "api/tasks/task"
end

Error:

ActionView::Template::Error (undefined method `card_image' for :task:Symbol):

Where "card_image" is a method call on the task in _task.json.rabl

@roelbondoc
Copy link

This should work (wrap the child and alias in braces):

child({:task => :todo}, :if => lambda { |publish_time| publish_time.task_id.present? }) do
    extends "api/tasks/task"
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants