1

Cheers! I have remote action in my rails project, smth like:

def foo
  respond_to do |format|
    format.js {}
  end
end

Somewhere in view:

= link_to "foo", foo_path, remote: true

In my foo.js.erb file:

$('#bar').html("<%= j render(partial: 'bar') %>");

In my _bar.html.haml partial:

hello, i am bar

It's all okay and well-working, but it returns me Missing template error when I refreshing page on this route. What's the problem?

xamenrax
  • 1,724
  • 3
  • 27
  • 47

1 Answers1

1

If you're mixing different formats (in this case, erb and haml), you'll need to specify the format of the partial.

This question provides the answer. Instead of render(partial: 'bar'), use:

$('#bar').html("<%= j render(partial: '/path/bar.html.haml') %>");
Community
  • 1
  • 1
Jon Cairns
  • 11,783
  • 4
  • 39
  • 66