Aug 27 2006

Mongrel for Flex and Rails development

Tag: RailsDerek Wischusen @ 9:56 pm

Most, if not all, all of the tutorials that I have seen about integrating Flex with Rails have used the WEBrick server that is included with Ruby.  While there is nothing wrong with using WEBrick for developing small apps on your local machine, I would recommend that most developers use Mongrel, especially if you are developing in a windows environment.

Mongrel (http://mongrel.rubyforge.org/) is going to get you much better performance than the CGI based WEBrick and it is just as easy to use.

To get Mongrel, make sure you have the latest versions of Ruby, Rails, RubyGems installed, then just run gem install mongrel from the command line and then follow the instructions on the screen.

To run Mongrel just go to the rails application that you want to run on the command line and run mongrel_rails start.

That’s it.  Just as easy as WEBBrick, and now your running in an environment that could be deployed for small scale apps.

Also, in honor of Zed Shaw’s (the creator of Mongrel) site here is a picture of my mongrel (Eva)

 My mongrel


Aug 27 2006

Simple FTP app using Flex and Rails

Tag: Flex and RailsDerek Wischusen @ 9:05 pm

Here is a simple app that I put together to demonstrate an integration between Flex and Ruby’s File and Directory utilities. It is not, by any means, meant to be a full FTP application (though I suppose it could, with some work, serve as the foundation for one).

Here is what you can do with it:

  • Create a new account or log into an existing account.
  • Create new subfolders in your account.
  • Upload .txt or .jpg files. Up to 1MB per account (look out Box.net).
  • Download files.
  • Delete files or folders.
  • Move files or folders by dragging them from the right panel dropping them on directory tree.

That’s about it.

Please consider this to be an alpha realease, as I am sure there will be bugs. If you do encounter a bug that you would like to report, please send an email to: bugs at flexonrails dot net

Finally, here is the link to the app: http://www.flexonrails.net/flexftp/public/

I will release the source as soon as I’ve had a chance to fix all the bugs and clean up the code a bit.

Credits:

[UPDATE 04/22/2007]

Ok, I never did get around to cleaning up the code for this app so the code is still in pretty rough shape, but a couple of people asked for the source recently, so I’ve decided to release the source as is in the hopes that at least some small parts of it will be useful to someone.

Download Source Here


Aug 17 2006

Save your CSS with the Flex 2: Styles Creator

Tag: Flex and RailsDerek Wischusen @ 9:07 pm

A while back I was playing around with the Flex 2: Styles Explorer (Developed by Adobe Consulting) and I thought to myself that it would be nice if you could save the CSS that you create with it.  Well, a little AS3 and Ruby later (see the previous post for details) and I present to you The Flex 2: Styles Creator. 

You can check it out here: http://www.flexonrails.net/stylescreator/public/

Simply use it as you would the Flex 2: Styles Explorer, but if you create something you really like, just click the Download CSS button (my minor contribution) in upper-right hand corner and download it to your machine.

In the future, I plan to build out the back-end so that you will be able to save to a database and share your Styles with everyone else.  I hope to get this done in a couple of weeks.


Aug 17 2006

Simple Ruby script for uploading files from Flex

Tag: Flex and RailsDerek Wischusen @ 10:06 am

Here is the AS3:

private var fileRef:FileReference = new FileReference();
private function uploadFile():void
{
 fileRef.addEventListener(Event.SELECT, selectHandler);
 fileRef.addEventListener(Event.COMPLETE, completeHandler);
 

try {
      var success:Boolean = fileRef.browse();
 } catch (error:Error) {
      trace("Unable to browse for files.");
  }
}
private function selectHandler(event:Event):void {

    // assumes the Ruby Method is in the application controller
    var request:URLRequest = new URLRequest("application/upload_file")
    try {
        fileRef.upload(request);
    } catch (error:Error) {
        trace("Unable to upload file.");
    }
}
private function completeHandler(event:Event):void {
 fileRef.removeEventListener(Event.SELECT, selectHandler);
 fileRef.removeEventListener(Event.COMPLETE, completeHandler);
 trace("uploaded");
} 

  

Here is the Ruby:
    def upload_file
      file_data = params[:Filedata]
      file_name = params[:Filename].to_s
      File.open(file_name, "wb") { |f| f.write(file_data.read) })
      render(:xml => "< success />" )
    end

That’s it.  Note, that if your running on a non-windows box you should change “wb” to “w”.


Aug 17 2006

Downloading data from Flex using Ruby send_data

Tag: Flex and RailsDerek Wischusen @ 10:00 am

I recently encountered a situation where I wanted to be able to download data from Flex directly to the user’s desktop.  Fortunately, Ruby provides a very simple way to do this using the send_data method, which sends data to the browser for download.  However, the way that you need to communicate with this method for it work properly is slightly different from how you would normally communicate between Flex and Rails. 

Usually, when you want to call a Ruby method you would use an HTTPService, but when you are calling send_data this will not produce the desired result. This is because the data will be returned back to the HTTPService inside of Flex, which is pretty useless (you are basically passing the data back and forth).  What you want is for the data to be returned to the browser so that the user can download it.

To solve this problem I used the Flex navigateToURL method along with a URLVariables object:

 private function saveToFile():void
  {
  var appUrl:URLRequest = new URLRequest();
  appUrl.url = "application/data_to_file";
  appUrl.method = URLRequestMethod.POST;
  
  var variables:URLVariables = new URLVariables();
  variables.content = "Downloaded from Flex!";
  variables.suggested_name = "download.txt";
           
  appUrl.data = variables;
  

  navigateToURL(appUrl, "_top");

}

The URLRequest object specifies the url of the method to call (the data_to_file method inside the application controller), the URLVariables object specifies the data to pass, and the navigateToURL method sends HTTP request through the browswer to data_to_file, which sends the data back to your browswer, which prompts you to download the file.

Here is the Ruby method:

    def data_to_file
      file_data = params[:content]
      suggestion = params[:suggested_name]
      send_data(file_data, :filename => suggestion)
    end

To see a simple example of this, check out the following post.


Aug 06 2006

Day 1

Tag: UncategorizedDerek Wischusen @ 7:23 pm

This site, whenever I get around to setting it up, will be dedicated to the Flex RoR community (all five of us).


Cialis order online
Phentermine online uk
Tramadol cod delivery
Purchase phentermine online
Viagra pharmacy prices
Where to buy propecia in canada
Tramadol without prescription overnight delivery
Cialis 20mg
Tramadol no prescription required
Buy viagra online in ireland
Generic viagra 100mg
Xanax generic dosage
Prescription propecia
Best prices for cialis
Phentermine buy uk
Low price cialis
Viagra lowest prices
Cheap valium online
Cheap xanax bars
Valium pill 10mg
Cheap cialis pills
Viagra canada mastercard
Dose of xanax
Cost of viagra 50mg
Phentermine with no prescription
Phentermine hcl no prescription
Prednisone tablets 10 mg
Buy phentermine online without prescription
Free cialis online
Buy phentermine 37.5mg online
Valium drug side effects
Valium online fast delivery
Buy xanax overnight
Phentermine canadian pharmacy
Low price viagra
Cheap generic viagra
Buying valium in spain
Get viagra prescription
Generic viagra online without prescription
Where to buy levitra online
Get viagra
Xanax with no prescription
Levitra online cheap
Cialis samples canada
Order prednisone no prescription
Buy phentermine no script
Genuine viagra online
Cialis purchase online
Viagra cheap no prescription
Tramadol prescription online
Valium online overnight
Viagra generic cheap
Tramadol medication
Best viagra dose
Xanax online cheap
No prescription valium
Brand viagra cheap
Buy viagra online in australia
Cheap xanax for sale
Buy xanax online without prescription
Phentermine online free shipping
Viagra in the uk
Buying cialis
Discount viagra usa
Purchase tramadol online
Where to buy cialis online
Where to buy viagra in england
Buy viagra from canada
Buy generic phentermine online
Pfizer viagra price
Viagra indian pharmacy
Buy levitra
Buy viagra australia
Cheap propecia without prescription
Levitra us
Generic xanax xr
Best price on phentermine
Phentermine 37.5mg side effects
Pharmacy tramadol
100mg tramadol effects
Viagra ordering
Xanax no prescription overnight
Get tramadol prescription
Generic tramadol
Xanax 0.5 mg
Cheap levitra no prescription
Buy xanax canada
Xanax 1 mg dose
Where to buy viagra online
Buy viagra in canada online
Tramadol pharmacy
Cheapest online cialis
Propecia cost
Buy generic propecia uk
Phentermine purchase online
10mg valium effects
Prescription viagra canada
Overnight tramadol no prescription
Propecia generic cost
Valium generic
Buying cialis online without a prescription
Xanax no rx
Cialis soft tabs online
Cheap 100mg viagra
Cialis medication
Prednisone dosages
No prescription cialis online
Buy valium cheap online
Buying viagra in new zealand
Cheap phentermine without prescription
Buying viagra in london
Cialis 20mg side effects
Canada viagra no prescription
Ordering cialis online
Viagra professional online
Cialis canada no prescription
Ordering propecia from canada
Viagra dosage information
Cheapest generic viagra online
Viagra in france
Valium online pharmacy
Viagra purchase uk
Phentermine 37.5 wholesale
Best price tramadol
Levitra canada
Buy valium europe
Valium cheapest
Buy cialis in the uk
Viagra super active
Buy female viagra without prescription
Valium 10 mg
Buy viagra 100mg
Generic cialis overnight
Propecia usa
Buy propecia
Where can i buy viagra in the uk
Buy tramadol hcl
Tramadol online overnight
Low cost levitra

Best way to take tramadol
Cheapest place to buy viagra online
Cialis dosage 20mg
Buy viagra uk online
Propecia 1mg generic
Xanax bars dosage
Where to buy phentermine cheap
Drug phentermine
Generic viagra sales
Where can i buy cialis without a prescription
Buy valium no rx
Order tramadol online cod
Tramadol without prescription
Tramadol for sale
Prescriptions for phentermine
Viagra prescription cost
40 mg prednisone side effects
Viagra express delivery
Buy generic cialis
Propecia ireland
Buy cheap valium online
Online valium without prescription
Prednisone 20mg side effects
Prednisone tablets
Propecia online uk
Buy viagra online cheap
Cialis prescription cost
Buy viagra in england
Xanax 1mg side effects
Buy phentermine 37.5mg pills
Buy valium without prescription uk
Purchase levitra online
Mail order phentermine
Cheapest cialis professional
Best viagra alternative
Phentermine buy australia
Xanax 1mg
Best price cialis
Viagra canada prices
Phentermine canada no prescription
Xanax bars side effects
Buy levitra online canada
Buying viagra online
Buy generic cialis online
Purchase cialis without a prescription
Buy cialis viagra
Prescription valium
Buy propecia online without a prescription
Cialis side effects
Cialis online canadian pharmacy
Viagra online purchase in india
Buying tramadol in uk
Order tramadol online overnight
Buy phentermine hcl 37.5 no prescription
Tramadol india
Purchase phentermine
Canada viagra
Propecia cheap
Real phentermine without prescription
Buy brand name viagra
Valium from india
Generic cialis uk
Viagra 50mg side effects
Cialis 10mg side effects
Free samples of cialis
Low cost cialis
Viagra online cheap
Viagra in the philippines
100mg tramadol online
Buy pfizer viagra without prescription
Viagra india price
Viagra canadian online pharmacy
Cheap tramadol overnight delivery
Phentermine 37.5 pills
Viagra pharmacy uk
Phentermine diet pills without prescription
Where to buy cialis without prescription
Generic xanax no prescription
Propecia uk pharmacy
Xanax price per pill
10mg prednisone
Blood pressure and prednisone
Viagra without prescription uk
Viagra buy online no prescription
How to buy valium without a prescription
Viagra 50 mg online without prescription
Order tramadol cod
Buy viagra online uk no prescription
Xanax bars effects
Cialis 20 mg dosage
Levitra price
Cheap cialis soft tabs
Buy tramadol cod
Xanax no prescription required
Valium without prescription
Discount viagra online
Buy tramadol overnight
Discount viagra pills
Best levitra prices
Xanax overnight cod
Canada pharmacy valium
Tramadol online no prescription overnight
Buy viagra uk no prescription
Overnight delivery viagra
Propecia price
Cheap 37 5 phentermine
Dosage of xanax
Cheap cialis
Side effects of viagra
Cialis ordering