top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to pass a Rails variable into JavaScript within Rails

0 votes
619 views

I have a variable created by some rails in my controller that looks like this:

@myvar= row["myvar"]

and I want to pass it into some javascript that is referenced from within my view:

view:

js (play_time):

I am trying to pass " into the js [obviously that is not the right syntax]. Can anyone help?

posted May 29, 2014 by Mandeep Sehgal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

gon gem is great for this and can be downloaded
https://github.com/gazay/gon

answer May 29, 2014 by Naveena Garg
Similar Questions
0 votes

I am building a multi-page rails web app and am struggling with finding a good JavaScript framework to use. I could use jQuery for all the low-level DOM manipulations but would like to benefit from the structure of a good framework.

+2 votes

I have added few libraries in my application and I have tested it in my local machine and they are working. But when I host it on my server and set the env to productions those libraries are not loading or the effects are appearing on my page.

...