Reputation: 9580
I want to use SoundManager2 to play sounds in my Ruby on Rails application. One of the things it wants is a directory with swfs. Where do I put it and then how do I configure my soundmanager? I want to put them in a directory /soundmanager/ and use JS such as the following:
<script>
if (soundManager) {
soundManager.setup({
url: '/soundmanager/',
onready: function() {
var myGameMusic = soundManager.createSound({
id: 'music1',
url: 'music1.wav'
});
myGameMusic.play();
},
ontimeout: function() {
console.log("Error in soundManager.setUp")
// Hrmm, SM2 could not start. Missing SWF? Flash blocked? Show an error, etc.?
}
});
}
</script>
Where do I put the swfs (/soundmanager/) and how do I configure it to be public?
A related question is: suppose I have some PDFs that I want to make downlaodable. Where do I put those so that they're downloadable?
I'm confused because there is a /public directory but apparently it doesn't work in rails 3.1 anymore.
Upvotes: 2
Views: 318
Reputation: 96484
You put them in app/assets/
The key is that they are served from there in development mode.
In production mode, the assets are minified and placed in public/
This is called 'asset compilation' and was introduced in Rails 3.1 and has caused a lot of confusion as you have seen.
Upvotes: 1
Reputation: 6682
The web server should be serving static resources alongside Rails (not through Rails).
I had to do this to get a phpMyAdmin installation working with a Rails app on Apache/Passenger.
# Apache vhosts.conf
<Location ~ "/static_content">
PassengerEnabled off
</Location>
This serves content in /static_content
directly from Apache, bypassing Rails completely. Ideally, this is the optimal solution to static content in any case.
Upvotes: 1