I need help in displaying the output of a rails helper method inside the script tags in the application.html.erb layout file. I put the following code just before the closing html tag:
<script>
App.ready = function() {
App.initApp(jQuery.parseJSON("<%= current_user_json %>"));
}
</script>
This current_user_json is a helper method that is in the application controller file.
The output the above code produces in the browser(view page source) is:
<script>
App.ready = function() {
App.initApp(jQuery.parseJSON("{"id":3,"email":"user5@user.com","username":null}"));
}
</script>
The proper output should be:
<script>
App.ready = function() {
App.initApp(jQuery.parseJSON('{"id":3,"email":"user5@user.com","username":null}'))
}
</script>
If someone could help me out, I will really be relieved of this problem I am trying to resolve for the past couple of days.
Aucun commentaire:
Enregistrer un commentaire