peaksandvalleys
peaksandvalleys

Reputation: 43

Proper syntax for including a ruby variable in an Ajax call inside a SLIM view

Rails
Ajax
SLIM

I would like to use SLIM for my Rails views, but I can't figure out the syntax for using a Ruby variable inside an Ajax call.

If my view has an html.erb extension, I can put in it something like this:

<script>
  $('#MyDivId').replaceWith({
    ajax: '/users_activities?email=<%= @user.email%>'
  });
</script>

But, if this was a .html.slim view, if I do:

javascript:
  $('#MyDivId').replaceWith({
    ajax: '/users_activities?email=<%= @user.email%>'
  });

I would get an error message. Any idea what the proper syntax is for doing this in SLIM?

Upvotes: 0

Views: 109

Answers (1)

arieljuod
arieljuod

Reputation: 15838

Use this:

'/users_activities?email=#{@user.email}'

Upvotes: 1

Related Questions