Reputation: 10412
I'm using HAML to return js for remote:true
form
Below is my code:
$('#chat-message').val('');
$('ul.chat').append('#{j render(@chat)}');
This line seems to create an error and does not parse correctly.
When I delete the second line it works fine with first line.
What could be wrong?
Below is the error:
ActionView::MissingTemplate at /chats
=====================================
> Missing partial chats/chat with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}. Searched in:
* "C:/BitNami/rubystack-2.0.0-4/projects/virtual_exhibition/app/views"
* "C:/BitNami/rubystack-2.0.0-4/ruby/lib/ruby/gems/2.0.0/gems/jasmine-rails-0.4.9/app/views"
* "C:/BitNami/rubystack-2.0.0-4/ruby/lib/ruby/gems/2.0.0/bundler/gems/bigbluebutton_rails-2c99a8402df4/app/views"
* "C:/BitNami/rubystack-2.0.0-4/ruby/lib/ruby/gems/2.0.0/gems/devise_invitable-1.3.1/app/views"
* "C:/BitNami/rubystack-2.0.0-4/ruby/lib/ruby/gems/2.0.0/gems/devise-3.2.1/app/views"
app/views/chats/create.html.haml, line 2
----------------------------------------
``` ruby
1 $('#chat-message').val('');
> 2 $('ul.chat').append("#{j render(@chat)}");
Upvotes: 0
Views: 1046
Reputation: 38645
You need to use double quotes "
not single quotes '
for expression inside #{j render(@chat)}
to be evaluated:
$('ul.chat').append("#{j render(@chat)}");
Upvotes: 1
Reputation: 115511
To get string interpolation you need " ", not ' '
So do:
"#{j render(@chat)}"
Upvotes: 1