Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement a 'safe' periodical executer without using the Rails helpers?
    primarykey
    data
    text
    <p>I am very new to Ruby on Rails and was never really big on writing JavaScript, so the built in helpers were like a tiny silce of heaven. However I have recently learned that using the helper methods creates "obtrusive javascript" so I am doing a tiny bit of refactoring to get all this messy code out of my view. I'm also using the Prototype API to figure out what all these functions do.</p> <p>Right now, I have:</p> <pre><code>&lt;%= periodically_call_remote(:url =&gt; {:action =&gt; "tablerefresh", :id =&gt; 1 }, :frequency =&gt; '5', :complete =&gt; "load('26', 'table1', request.responseText)")%&gt; </code></pre> <p>Which produces:</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ new PeriodicalExecuter(function() {new Ajax.Request('/qrpsdrail/grids/tablerefresh/1', {asynchronous:true, evalScripts:true, onComplete:function(request){load('26', 'table1', request.responseText)}, parameters:'authenticity_token=' + encodeURIComponent('dfG7wWyVYEpelfdZvBWk7MlhzZoK7VvtT/HDi3w7gPM=')})}, 5) //]]&gt; &lt;/script&gt; </code></pre> <p>My concern is that the "encodeURIComponent" and the presence of "authenticity_token" are generated by Rails. I'm assuming these are used to assure the validity of a request. (Ensuring a request comes from a currently active session?)</p> <p>If that is the case, how can I implement this in application.js 'safely'? It seems that the built in method, although obtrusive, does add some beneficial security.</p> <p>Thanks, in advance, to all who answer.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload