Skip to content

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

@the-teacher

Description

@the-teacher

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions