Rails audio_tag - audio

Hello everyone I am trying to get an audio tag to work in rails. I am using the syntax
<%= audio_tag "somesong.mp3", :controls => true %>
However when I utilize this format it throws an error.
This is the output file created by the audio tag.
This is the error that gets thrown in my song folder
Routing Error
No route matches [GET] "/audios/sunshine.ogg"
Try running rake routes for more information on available routes.
This is my routing table that shows the routes I am using.
eric#ubuntu:~/Desktop/Musicband/musicband_app$ rake routes
contacts GET /contacts(.:format) contacts#index new_contact GET /contacts/new(.:format) contacts#new
contact PUT /contacts/:id(.:format) contacts#update
songs GET /songs(.:format) songs#index
POST /songs(.:format) songs#create
new_song GET /songs/new(.:format) songs#new edit_song GET /songs/:id/edit(.:format) songs#edit
song GET /songs/:id(.:format) songs#show
PUT /songs/:id(.:format) songs#update
DELETE /songs/:id(.:format) songs#destroy
groupees GET /groupees(.:format) groupees#index
POST /groupees(.:format) groupees#create new_groupee GET /groupees/new(.:format) groupees#new
edit_groupee GET /groupees/:id/edit(.:format) groupees#edit
groupee GET /groupees/:id(.:format) groupees#show
PUT /groupees/:id(.:format) groupees#update
DELETE /groupees/:id(.:format) groupees#destroy
audio /audio(.:format) landing_pages#music
/contact(.:format) contacts#new
about /about(.:format) landing_pages#about
root / landing_pages#home
I don't know how to fix this audio problem and get it working. Also where is the audio files stored by default? This is kind for a class project that I am trying to get done pretty soon.
So if there is someone out there who knows how to fix this, I would greatly appreciate it.
Thanks.

You haven't set up the appropriate routes in your routes.rb file.
You need to either add resources :audios and have an audios controller set up to handle the request or if audios is an alias for another controller, set that up accordingly.
--edit--
If you want to serve the audio file through a controller you'll need send_file but really I'd recommend just serving static assets from an asset folder instead of through a controller, which just adds overhead. You only need the controller if you're going to add/change sounds.
Read up on the asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html

Related

How can I make Plone portal registries find and cook new-style static resources?

All JS I register with an id such as ++theme++mythemename/js/myscript.js gives me the following error on portal_javascripts: (resource not found or not accessible)
I know the id is correct because I can access localhost/mysite/++theme++mythemename/js/myscript.js (even if Diazo is disabled).
If development mode is on the resource gets delivered on the final HTML. However on production mode cooking process fails silently. Or almost. Besides getting a different cachekey than the one showed on portal_javascripts/manage_jsComposition, I see the following error message by accessing the cooked file:
/* XXX ERROR -- access to '++theme++mythemename/js/myscript.js' not authorized */
Any hints on how to deal with those? Or will I really need to leave them uncooked?
Have you tried a browser:resourceDirectory instead of a plone:static ?
<browser:resourceDirectory
name="yourJsFolder"
directory="yourJsFolder"
layer=".interfaces.IThemeSpecific"
/>
and calling your js with :
++resource++yourJsFolder/yourJsFile.js
i added your observatorio.tema package to an existing plone 4.1 buildout and added a random js file to the js registry (positioned after collapsibleformfields.js so it gets properly cooked)
GS export looks like:
<javascript authenticated="False" cacheable="True" compression="safe"
conditionalcomment="" cookable="True" enabled="True" expression=""
id="++theme++observatorio/js/ui.js" inline="False" insert-after="collapsibleformfields.js"/>
no error in portal_jacascripts and the javascript file is included in /jquery-cachekey-e7bee35d43da7a91eb29c6586dcbd396.js
did you add cacheable="False" and cookable="False" for testing purposes?
https://github.com/observatoriogenero/observatorio.tema/blob/master/src/observatorio/tema/profiles/default/jsregistry.xml#L373
since plone:static internally is a resourceDirectory both should and do work with resourceregistries.
maybe there is some other code in your buildout that re-registers another (empty) directory for the same name (observatorio)?

How to do navigation durandal.js?

i am trying to use durandal.js for single page architecture,
i already have application where i am loading all pages in div = old approach for single page architecture,
what i want to do is when i click on page i need to open hotspa pages,
for now i write something like this . www.xyz.com#/details,
where # details is my durandal view page!
when i put <a> herf ....#/details, i got error like this :
http://postimg.org/image/hoeu1wiz5/
but when i refresh with same url, it is working fine, i am able to see view!
i do not know why i got this error
If you are using anything before version 2.0 of Durandal, you are getting this because in your Shell.js you are not defining router, or you have a bad definition of where the router module is, or possibly you are defining scripts in your index instead of 'requiring them' via require.js
1st - Check shell.js, at the top you should have a define function and it should say / do something like this, and should be exposing that to the view like so -
define(['durandal/plugins/router'], function (router) {
var shell = {
router: router
};
return shell;
};
2nd - Check and make sure the 'durandal/plugins/router' is point to the correct location in the solution explorer, in this case it is app > durandal > plugins > router. If it is not or if there is no router you can add it using nuget.
3rd - Make sure you aren't loading scripts up in your index or shell html pages. When using require.js you need to move any scripts you are loading into a require statement for everything to function properly. The 'Mismatched anonymous define() module' error usually occurs when you are loading them elsewhere - http://requirejs.org/docs/errors.html#mismatch

How to upload a file to a user after a front-end action in Node.js

I'm working on a project built entirely in node.js and coffeescript. I want to allow the user to export a CSV of several different collections in my Mongo DB by clicking a button on my website.
I believe the best way to do this would be to make an ajax call to my node.js backend and have that call return somefile.csv to the user. I'm at a loss at how to do this though, and there are so many conflicting resources. Here's the stub of how I think things should work:
exports.exportToCSV = (req, res) ->
console.log 'Inside exportToCSV'
# Create a dynamic csv file
# How to?
# Set the response headers
# How to?
# Attach the newly created CSV
# How to?
# Write the response
res.write('somefile.csv')
res.end()
Any help would be greatly appreciated. Thank you.
If you're using Express (and I'd say you need a pretty big excuse not to), everything after creating the CSV is a piece of cake:
res.download 'somefile.csv'
As the Express docs explain, that's shorthand for
res.attachment 'somefile.csv'
(which sets the headers) and
res.sendfile 'somefile.csv'
If you want to understand how it all works, here's the source: https://github.com/visionmedia/express/blob/master/lib/response.js
As to creating a CSV, I've never had to do this, but you can't go wrong searching npm for "csv".

How do I write log messages in Kohana 3.2?

Ok I've tried searching all over but can't seem to get just a simple straight forward answer.
I want to write log messages (INFO, ERROR, etc.) to the Kohana log file /application/logs/YYYY/MM/DD.php.
How do I do it?
Try the log class add() method: http://kohanaframework.org/3.2/guide/api/Log#add
Call it like this:
Log::instance()->add(Log::NOTICE, 'My Logged Message Here');
For the first parameter (level) use one of the 9 constants defined in the log class
Shuadoc you shouldn't touch system files (all those under system folder).
Change the value in bootstrap.php instead as stated by Ygam
Otherwise, when updates come you'll be in trouble.

implementing uploadify in kohana 3

I have a hard time implementing uploadify inside kohana 3, what changes should I make to the originial uploadify.php? just making it the index function in a controller doesn't work and returns a 500 error.
Thank you!
I'm not too sure if this will help, but I spent many hours dealing with uploadify the other day, and one of the tricks was to give back ANY response from the upload controller to let uploadify know that uploading is done.
Solution as simply as this: $this->request->response = "OK";
However, 500 states for interval server error, so the case might be also passing session ID with the 'scriptData' parameter when initializing uploadify, like this:
$('#file_upload').uploadify({'scriptData': {'<?php echo $session_name; ?>': '<?php echo session_id(); ?>'}});
Hope this helps, cheers!
Are you using Uploadify 2.1.x or 3.0 beta?
Anyway, you should be able to use any controller you want as long as you set the parameters in the javascript accordingly. And make sure you're not using a template for the controller dealing with the file uploads.
For instance, if you have a controller "files" and an action "uploadify" at URI /site/files/uploadify you should set the parameter to something like this:
'script' : '/site/files/uploadify',

Resources