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

Cant access instance in Rabl template with Grape #392

Open
amrnt opened this issue Jan 20, 2013 · 2 comments
Open

Cant access instance in Rabl template with Grape #392

amrnt opened this issue Jan 20, 2013 · 2 comments

Comments

@amrnt
Copy link

amrnt commented Jan 20, 2013

I'm using Rabl with Grape.

I have this view, but @comments is nil here!

object false

node :meta do
  {total: @comments.count}
end

child @comments => :data do
  attributes :id, :message
end

I use this as initial config:

Rabl.register!

Rabl.configure do |config|
  config.include_json_root = false
  config.enable_json_callbacks = true
  config.view_paths = [File.expand_path('../../../api/views', __FILE__)]
end

class RablPresenter
  def self.represent(object, options)
    Rabl::Renderer.new(options[:source], object, format: options[:env]['api.format']).render
  end
end
@nesquena
Copy link
Owner

Are you using https://github.com/LTe/grape-rabl that has been updated and you may want to see if that solves your issue. Also, whats the call from the RablPresenter from within your grape routes?

@amrnt
Copy link
Author

amrnt commented Jan 20, 2013

LTe/grape-rabl works fine, but I was wondering why Grape not working with Rabl::Renderer

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