Tagged Questions
174
votes
20answers
29k views
Using Rails 3.1, where do you put your “page specific” javascript code?
To my understanding, all of your javascript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your application.js manifest file.
This sounds like a ...
38
votes
6answers
49k views
Facebook how to check if user has liked page and show content?
I am trying to create a Facebook iFrame app. The app should first show an image and if the user likes the page, he will get access to some content.
I use RoR, therefore I can't use the Facebook PhP ...
72
votes
7answers
21k views
Best way to add page specific javascript in a Rails 3 app?
Rails 3 has some unobtrusive javascript which is pretty cool.
But I was wondering what the best way is to include additional JS for a particular page.
For example, where I might have previously ...
54
votes
6answers
24k views
Rails - Could not find a JavaScript runtime?
I created a new Rails project using rails 3.1.0.rc4 on my local machine but when I try to start the server I get:
Could not find a JavaScript runtime. See here for a list of available runtimes. ...
46
votes
8answers
82k views
jQuery: how to change title of document during .ready()?
I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set ...
18
votes
2answers
4k views
“Can't find variable” error with Rails 3.1 and Coffeescript
I have views in my application that reference my application.js file which contains functions I use throughout my application.
I just installed the Rails 3.1 release candidate after having used the ...
34
votes
4answers
17k views
Why escape_javascript before rendering a partial?
I'm looking at this Railscast episode and wondering why the call to escape_javascript is needed here:
$("#reviews").append("<%= escape_javascript(render(:partial => @review)) %>");
What is ...
23
votes
11answers
21k views
Is it possible to ping a server from Javascript?
Just what the title says. I'm making a web app that requires that I check to see if remote servers are online or not. When I run it from the command line, my page load goes up to a full 60s (for 8 ...
22
votes
4answers
14k views
JavaScript file per view in Rails
As per 'unobtrusive JavaScript' recommendations I want to separate my JavaScript logic into
separate files. However I don't know how to organize them.
Should I:
Just throw all application ...
12
votes
3answers
847 views
rails and backbone working together
I am just starting to look at MVC structure, first i looked at how backbone.js worked, and now I have just completed rails for zombies, by Code School. I know that I haven't delved too far into any of ...
12
votes
5answers
4k views
ExecJS::RuntimeError on windows 7 trying to follow rubytutorial
UPDATE: Colin's suggestion of removing the line //= require_tree . has fixed the issue.
I have wasted over 2 days trying to follow every suggestion out there and fix my issue. I am trying to follow ...
20
votes
6answers
6k views
Find DOM element by ID when ID contains square brackets?
I have a DOM element with an ID similar to:
something[500]
which was built by my Ruby on Rails application. I need to be able to get this element via jQuery so that I can traverse my way up the ...
38
votes
4answers
19k views
Problem deploying Rails 3.1 project to Heroku: Could not find a JavaScript runtime
I am having trouble deploying a rails 3.1 beta project to heroku. The problem happened at the database migration step. When I ran:
heroku rake db:migrate
I got error message:
> rake aborted!
> ...
12
votes
2answers
11k views
.js.erb VS .js
What is the advantage to putting you javascript for your rails app into a .js.erb file instead of just throwing it in your application.js file? I have a create button for businesses so should I put ...
9
votes
4answers
8k views
jQuery UI Dialog instead of alert() for Rails 3 data-confirm attribute
In Rails 3, passing a :confirm parameter to link_to will populate the data-confirm attribute of the link. This will induce a JS alert() when the link is clicked.
I am using the rails jQuery UJS ...