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

Problem with ApplicationController.render when it renders JBuilder template #3

Open
the-teacher opened this issue Oct 5, 2016 · 0 comments

Comments

@the-teacher
Copy link
Member

the-teacher commented Oct 5, 2016

I think, ApplicationController.render should return data in json format when it works with jbuilder templates. Right now it returns a string.

There is a similar problem and expectation from SO user:

http://stackoverflow.com/questions/39103685/can-you-invoke-jbuilder-to-create-a-native-rails-object-instead-of-a-rendered-st

Right now I solved it with simple helpers, like this:

module ChannelHelper
  def render_view(params)
    ApplicationController.render(params)
  end

  def render_json(params)
    JSON.parse render_view(params)
  end

  def broadcast channel, message
    ActionCable.server.broadcast channel, message
  end
end

https://github.com/DeployRB/Rails5App/blob/master/app/channels/notes_channel.rb#L18

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

1 participant