I'm facing an issue embedding flash content in a Ruby on Rails 3 view for the show operation:
By convention when you define a resource in routes.rb and then access a URL like /<controller&g开发者_JS百科t;/<id>
the show method of the corresponding controller is called with the <id>
value copied into params[:id]
so you can use it to retrieve data from you model.
However, when I embed Flash content on such a page using the dynamic embedding via swfobject.embedswf(swfUrlStr,...) the id parameter is overwritten by it now containing the swfUrlStr which is then passed to the controller.
Is there any elegant way to work around this issue?
Any pointers appreciated :)
OK, I figured out the problem:
The second request was in fact just the GET request to load the SWF file to embed. Since I put in a relative URL it was sent to the same controller:
swfobject.embedSWF("Dummy.swf", [...]);
Using an absolute path like this
swfobject.embedSWF("/videos/Dummy.swf", [...]);
does not entail an additional call to the controller.
Thanks for watching, everybody!
精彩评论