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.
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.