Posts by Category: My Site
Embedding Flash Content on a Rails App
Recently I've been trying to write a post about the use of toolbars with a Flex application. The post is coming along slowly, almost there as I write this, but I had a problem embedding the Flex app. within my blog post.
Essentially the embedded Flash object (.SWF file) wasn't appearing on my blog page.
My hosting company is DreamHost and so I had a quick look at the DreamHost wiki and forum but couldn't really find anything related to my specific problem. Of course it doesn't help when you're trying to search when there's a Ruby on Rails command named 'flash'!
I played around with my local copy of my web site and got the Flash content working after a short while. I uploaded the code to my site but the hosted site was still not working.
At some point I stumbled upon a forum where someone's advice was to take a look at the error.log file on the server; this forum post was unrelated to my Flash problem but it gave me a vital clue. I then viewed the error.log file on my host server and discovered that the attempt to fetch my .SWF file was failing due to a 'Permission denied' error. At this stage I was thinking that the permissions at the location at which I had stored by .SWF file were preventing my browser from accessing this content, and I was right.
After issuing a 'chmod 755 public/images/*' command everything began to work. Here's the HTML code that I used to embed my Flash/Flex content:
1: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
2: WIDTH="400" HEIGHT="400">
3: <PARAM NAME="movie" VALUE="/images/ToolbarDemo.swf">
4: <!--[if !IE]>-->
5: <object type="application/x-shockwave-flash"
6: data="/images/ToolbarDemo.swf" width="400" height="400">
7: <!--<![if !IE]-->
8: <p>Flex demo of toolbar</p>
9: <!--[if !IE]>-->
10: </object>
11: <!--<![endif]-->
12: </object>
Posted by Graham Blake on 19th February 2009 at 13:29
Getting Hosted
I had a number of problems getting this site up and running with my host at first. I don't know what problems I'm going to encounter in the future but, at the moment, those problems have all been fixed and all is working well.
Don't know how the site will cope if people ever add any comments to my posts! The site was working well on my local PC but there were a number of issues to be resolved when the site finally got uploaded to my host.
For the first problem that I encountered I was getting an Application Error page whenever I viewed my site in a browser but my dispatch.fcgi file was working fine at the command prompt. The error.log file was reporting an incomplete header problem. After a little reading up on the DreamHost wiki page I found some information relating to this in the 'Common Gotchas' section under Symptom 1.2. Some time's passed since that first problem and I cannot recall exactly what I discovered but I followed the recommendation detailed in the wiki and this solved the problem. The solution was to change the 'group' of all of my files back to the default group.
The second problem related to the will_paginate gem. This is a pagination solution that I use to paginate post and news information on the administration pages of my site. I discovered that there were no problems if I commented out the require 'will_paginate' entry from my environment.rb file but if I put it back in it didn't seem to recognise the gem. I looked again at the Rails page of the DreamHost wiki and found the solution. The solution was to add the following line to my environment.rb file:
config.load_paths += %W( #{RAILS_ROOT}/vendor/will_paginate-2.2.2/lib )
I'm not sure why the gem wasn't being added to the gem load path but I got the result I needed. The final problem was obscure, at least it seemed that way to me. When I attempted to login to the admin section of my site and clicked the Login button I would get a dialogue box appearing which essentially meant that the browser wasn't receiving valid data.
Firefox would show a dialogue box saying something like, "You have chosen to open blog which is a: BIN file" ('blog' being the name of the page that I was attempting to access). Internet Explorer would show a dialogue which mentioned an application/octet-stream issue. The confusing thing was that this didn't happen all of the time. It seemed to happen in both of those browsers that I've mentioned and occurred on Windows and on Linux (Ubuntu). However, I didn't realise that this was a clue at the time, when I tried to log in to my site from my place of work everything was successful. I continued to put up a few posts on Rails specific forums and the DreamHost forum. The help came from the Working with Rails forum. Two of the guys who responded to my post seemed to think that it sounded like a server configuration problem, saying that my code seemed fine. One thing to mention is that the problem related to a redirect_to call; this was where the problem was revealing itself.
Now thinking that there was a server configuration problem I raised a help ticket with DreamHost to get the problem looked at. Unfortunately they were convinced that it was my code that was causing the problem, and of course they're not going to help someone debug their code so that was that. I was back to square one.
It was at this point that I decided to investigate a little further from my side. I asked a friend to access the site and tell me if he encountered the same problems that I was having. He did have the same problem. He was accessing the internet via a wireless connection, and so was I. I decided to connect my PC directly to my router, thereby using a wired connection rather than a wireless connection. The result was that for something like 9 attempts out of 10 to log in to my site it was successful, I didn't get the problem.
I went back to the Working with Rails forum and added to the growing post, telling them about my experience with the wired and wireless connections. That's when one of the guys contributing to the forum found the problem. It was related to the automatic gzip encoding that was taking place on the DreamHost server. Basically the gzip encoding was occurring if I accessed the site with a slow connection (my home network, especially with the wireless router) but encoding was not happening if the site was accessed with a fast connection (my work network). I raised another help ticket with DreamHost asking them to switch off gzip encoding and all is now well.
Phew! That was a bizarre problem that I would have been unable to fix without the help from the forums. So many thanks go to Jason King. If it wasn't for your help I'd still be struggling with this issue now.
Here's a link to the discussion at the Working with Rails site for anyone who's interested.
Posted by Graham Blake on 19th February 2009 at 13:29
First Post
Finally! I've finally managed to get this little site of mine online. I'm very pleased about this. I set myself a deadline of Christmas 2008 to get the site online and I've missed that by a little over 1 month. The site is written with Ruby on Rails and is being hosted by Dreamhost and I'm quite happy with the result; although I'll possibly put up a post in a short while discussing all of the aspects of the site that I'm not happy with, that's just how I am.
I actually had the site up and running about 2 weeks ago but had a couple of problems that had to be resolved before the site could be used (before I could write this first post for example). Details of these problems will come in future posts, however I just want to take the time to thank Jason King (his blog can be found at http://flow.handle.it/). If it wasn't for his assistance and response to my query at the workingwithrails site I would still be tearing my hair out and trying to work out why my site was plagued by, as I saw it, a rather obscure problem. So, thanks Jason.
Posted by Graham Blake on 19th February 2009 at 13:29