I have the next variable in my main_controller.rb:
def create:
@token = "24vgd32"
end
in my views/create.erb, I wrote:
<%= javascript_tag do %>
window.my_token = '<%= j @token %>';
<% end %>
by this way, I can use this variable in any of the JavaScript files that this page references.
but how can I use it in my application.js?
this is my application.js:
$(document).ready(function(){
licensario.getLicense({
wizardToken: my_token
});
});
any help appreciated!
In your create.html.erb use this
replace the some_field_id and my_token with desired names.
In your javascript file