Vixiom Axioms

October 31, 2006

Adobe Flex Builder 2 for Mac Beta

Filed under: Flex Alastair @ 11:37 am

Go grab it from Adobe Labs

I’ve been using it for a while now and can say that it has helped me be more productive compared to my old method of using TextMate and the Flex SDK, mainly because the build times out of Flex Builder are a couple of seconds while the SDK takes 10-30 seconds to compile.

However even with the slow build time TextMate is such a great editor and I’ve become so proficient with it - firing off tab triggers left and right, it’s made using an Eclipse based IDE feel a bit awkward.

On the other hand, compared to building apps in Flash, Flex Builder is a HUGE step up. ActionScript 3 is finally a real programming language with lots of new goodies like regular expressions. Compared to the various Javascript widget libraries Flex’s components are much more full featured and cohesive which gives your app an overall look and feel. One set of well designed components speeds up development tremendously, as you don’t have to switch mental gears because you’re using the rich text editor from one library and the color picker from another.

Speaking of switching gears the main cause of my vacillation with using Flex is Rails. You can get apps going so quickly with Rails that, unless I need some specific components, I’m more likely to use it for less complicated jobs. It doesn’t help that Abobe is really pushing Flex as a front-end for Java or Coldfusion apps while other languages are virtually ignored (especially in the documentation). I’m not asking that Adobe support the five of us who use Flex with Rails ;-) but a few more back-end agnostic examples would help.

One big advantage that Flex has is the soon to be released (early 2007) Apollo. Having an app that runs in a browser or as a ‘real’ stand alone desktop application without the need to rewrite any Flex code is a giant plus. Apollo apps will behave like other native applications with file i/o, windowing, a clipboard, system drag and drop, and local storage. Sites like last.fm have already proven that users can benefit from an installed app that integrates with the remote site. You could start building an app in Flex now and then port it or supplement it with Apollo in a couple of months.

Here are some resources for using Flex with Rails

flexonrails.net
flexiblerails.com (I’m half-way through the Flexible Rails book and so far it’s excellent)
Adobe RIA RoR SDK
WebORB for RoR
Textmate Flex/MXML Bundle

Digg! submit Adobe Flex Builder 2 for Mac Beta to stumbleupon.com submit Adobe Flex Builder 2 for Mac Beta to del.icio.us submit Adobe Flex Builder 2 for Mac Beta to reddit.com Like this post? subscribe to the feed.

October 24, 2006

Ensure that rails sessions remain valid over subdomains and https

Filed under: Ruby on Rails Alastair @ 11:43 am

If you’re using Active Record Store for your sessions (keeping sessions in a database) you may ‘lose’ your sessions when jumping to a subdomain or to a https connection (in my case it was the latter).

Here’s how to make sure your sessions don’t go walk about.

Add this line to your ‘config/environments/production.rb’ file

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => ‘.mydomain.com’)

obviously replacing ‘mydomain.com’ for the domain in question.

Digg! submit Ensure that rails sessions remain valid over subdomains and https to stumbleupon.com submit Ensure that rails sessions remain valid over subdomains and https to del.icio.us submit Ensure that rails sessions remain valid over subdomains and https to reddit.com Like this post? subscribe to the feed.

October 21, 2006

Use a partial form with form_for

Filed under: Ruby on Rails Alastair @ 12:56 pm

I’m sure the cool kids know this already but it gave me a problem so I thought I’d post it.

When using “render :partial => ‘form’”, where ‘form’ is being rendered for a ‘new’ and edit ‘view’, you need to pass a local variable for your model object.

Originally I had

<% form_for :product, @product, :url => { :action => ‘update’, :id => @product.id } do |f| %>

<!–[form:product]–>
<div id=container>
    <%= render :partial => ‘form’ %>
</div>

<button type=“submit”>Save Listing</button> 

and here’s the solution with ‘f’ passed as a local variable to the partial

<% form_for :product, @product, :url => { :action => ‘update’, :id => @product.id } do |f| %>

<!–[form:product]–>
<div id=container>
    <%= render :partial => ‘form’, :locals => { :f => f } %>
</div>

<button type=“submit”>Save Listing</button> 
Digg! submit Use a partial form with form_for to stumbleupon.com submit Use a partial form with form_for to del.icio.us submit Use a partial form with form_for to reddit.com Like this post? subscribe to the feed.

October 19, 2006

Use javascript/prototype to get a text field value for link_to_remote

Filed under: JavaScript, Ruby on Rails Alastair @ 6:16 pm

This one was a headache, and by headache I mean I was literally pounding my head on the desk trying to figure it out.

I wanted to use link_to_remote to create a model from another model’s form. The example being a ‘Product’ model that belongs to a ‘Group’, the user would select which group a product belonged to within the Product form. Within being the key word because you can’t use ‘remote_form_for’ because it will submit the ‘master’ form.

The solution I came up with was to use link_to_remote instead, but how to pass a text_field’s value to link_to_remote’s arguments. After hacking away I gave up and shot an email off to the AHG Software folks who have worked with me on a couple of Rails projects.

The answer was to use prototype’s $F() function which returns the value of any field input control.

<div id=group>
    <ul id=group_list>
        <%= render :partial => ‘groups/group_list’, :collection => @groups %>
    </ul>
    <% @group = Group.new %>
    <%= text_field ‘group’,‘name’ %><br />
    <%= link_to_remote “Add Group”,
    { :update => “group_list”,
    :url => { :controller => “groups”, :action => “new”},
    :with => “‘group%5Bname%5D=’+$F(’group_name’)”,
    :position => :bottom },
    { :class => “add” } %>
</div>

The key line being

:with => “‘group%5Bname%5D=’+$F(’group_name’)”,

‘%5B’ and ‘%5D’ are opening and closing square brackets [], which become more familiar to Rubyists (Rubians?… San Diegons?) as ‘group[name]’.

Problem solved! - with a little help :)

Digg! submit Use javascript/prototype to get a text field value for link_to_remote to stumbleupon.com submit Use javascript/prototype to get a text field value for link_to_remote to del.icio.us submit Use javascript/prototype to get a text field value for link_to_remote to reddit.com Like this post? subscribe to the feed.

October 12, 2006

Media Temple Tames the Beast - New Ruby on Rails Hosting Service with Mongrel

Filed under: Cool Shise, Mongrel, Ruby on Rails Alastair @ 11:48 pm

Media Temple (gs)

For a long time deployment has been the giant stinky Grey elephant in the beautiful Ruby colored room. Rails makes developing an app a joy but for many, including me, deployment has been a bit of a nightmare. If you wanted shared hosting you went with folks who seemingly built their Rails set up by the seat of their pants; only allowed production apps with no errors (yeah right), killed your apps (sans restart), had non-existent tech support, or worst of all a magical combination of all of the above (I think I’m still waiting for my Dreamhost activation letter). The other solution, which I opted for, was to roll your own hosting on a VPS or dedicated server which involved a lot of research, conflicting docs, and the horror that is FastCGI. Mongrel has saved my arse on the private server front, and now it will be the foundation of Rails hosting for Media Temple’s new Grid Server (gs).

Putting the dog in the box

Each (gs) account has the ability to create Rails Containers into which you install Rails, MySQL AND/or PostgreSQL bindings and of course Mongrel. You then create your Rails app ‘rails appname’, create a user for managing the app, generate a .htaccess file, create a sym link and um… that’s it! You can then start/stop/restart your app with ‘mtr start appname’.

That is by far the easiest Rails install I’ve ever done shared or otherwise. A lot of gems are installed already and if anything is missing you can install it. There’s also up to 1GB of dedicated RAM for Ruby Apps. I’ve been helping beta test the setup and my apps are running on the (gs) as fast if not faster than on my VPS server that Media Temple also hosts.

Bu wait there’s more… Capistrano support is baked right in.

What else do I get?

I mentioned you can choose between MySQL or PostgreSQL dbs, PHP4 or PHP5 (if you must), plans start with 50GB of storage space and 1TB of Bandwidth, multi-site hosting with unique users for each host (i.e. sales@site1.com and sales@site2.com won’t conflict) and the whole reason it’s called the grid - you can expand instantly in case of traffic emergencies. Last but not least 24/7 tech support online or by phone.

I know this sounds like they’re paying me (no, but if you sign up make sure to put ‘vixiom.net’ in the referral box). I’m excited because they’ve met or surpassed all my Rails hosting needs and I don’t even have to switch companies! A lot of my projects for smaller clients can now be hosted for a fraction of a VPS or dedicated server.

Thank you (mt)! With a special thanks to Nate for answering all my RoR questions.

*UPDATE* Here’s a coupon for 10% off

Here’s a shot of the new control panel:


Media Temple Control Panel

Digg! submit Media Temple Tames the Beast - New Ruby on Rails Hosting Service with Mongrel to stumbleupon.com submit Media Temple Tames the Beast - New Ruby on Rails Hosting Service with Mongrel to del.icio.us submit Media Temple Tames the Beast - New Ruby on Rails Hosting Service with Mongrel to reddit.com Like this post? subscribe to the feed.

Education on Demand

Filed under: Misc. Alastair @ 5:56 pm

Other than doctors or scientists I’d say there’s no other industry than web development that requires more continuous education. I probably spend about 25% of my work week either learning something new or looking something up (usually the latter!)

I used to make treks to the bookstore but lately I’ve been buying stuff online, the first online book I bought was the ever popular AWDwR, last weekend I bought Flexible Rails (which is very good, taught me some Flex things I didn’t know as well).

Today I found Peep Code which are looooooong screencasts on topics like RJS Templates and TextMate Basics for Rails, very focused stuff that might not make it to print but is very desirable for the right market i.e. me :)

One on demand service I didn’t like was Safari by O’reilly. You could only download five chapters a month and it felt like you where been nickled and dimed. I would buy from them if I could download a PDF of an entire book, one at a time without a subscription, but they force you to read everything on the site.

Digg! submit Education on Demand to stumbleupon.com submit Education on Demand to del.icio.us submit Education on Demand to reddit.com Like this post? subscribe to the feed.

Debbugging Your Web Apps

Filed under: ActionScript, JavaScript, Ruby on Rails Alastair @ 5:29 pm

Debugging has come a long way in the last few years, the current crop of tools is making web development faster and easier than ever before.

A great tool I found today is FireBug (late to the party as usual). It let’s you what’s going on under the hood of the browser including JavaScript, CSS, HTML and Ajax. Aside from debugging your own code you can sneak a peak everyone else’s business (for inspiration of course not to copy and paste).

FireBug
FireBug highlighting a div

A tool I’ve been using since the early Remoting days is Charles, which shows you all the communication going on between your browser and server. Charles saved me big time a couple of years back when Flash started requiring crossdomain.xml files if your .swf wanted to access data from another web site. Long story short I missed the memo about cross domain files and couldn’t for the life of me figure out why my Flash file could connect to data when tested locally but not on the server. Charles let me know that the .swf was checking for crossdomain.xml. Problem solved.

Digg! submit Debbugging Your Web Apps to stumbleupon.com submit Debbugging Your Web Apps to del.icio.us submit Debbugging Your Web Apps to reddit.com Like this post? subscribe to the feed.

October 6, 2006

Designing Interfaces (the Book)

Filed under: Design Alastair @ 2:08 pm

Found a great site that’s a companion to the book ‘Designing Interfaces: Patterns for Effective Interaction Design’ by Jenifer Tidwell. Split into sections like ‘Getting Around’, ‘ Organizing the Page’ with images and descriptions of interface solutions it’s good place to pick up UI ideas you may not of thought about.

If the book is as good as the site it will be money well spent.

More from Jenifer… here’s a beautiful example of what a site map should look like.

Digg! submit Designing Interfaces (the Book) to stumbleupon.com submit Designing Interfaces (the Book) to del.icio.us submit Designing Interfaces (the Book) to reddit.com Like this post? subscribe to the feed.

Flex Example Apps

Filed under: Flex Alastair @ 11:22 am

The number one search on here is for “flex example apps” so I know it’s not only me looking for some guidance to get started with Flex 2.0.

I didn’t get into Flex the first time round, the price point was just a bit too high for a small business like mine to buy it. Now that Flex 2.0 has come out I’m having difficulty finding real world example apps or tutorials to follow so I can build solutions that will pay me in real world dollars.

Adobe to their credit have put out a lot of examples on the Flex Developer Center, they’re good for getting started but are pretty basic I can see how I would use validation, embedding assets, or handling events once I had my app going but how do I start it in the first place?

The example apps that ship with Flex are more real worldly but, unlike the samples mentioned above, are for the most part undocumented - many without even comments in the code to follow along with.

Two of the most important parts of Flex, states and components, took me a long time to find/get to in the documentation. For programmers new to Flex I don’t think they’ll dive into the docs and look for “custom components” when the problem they’re solving is code reuse or team development. States was easier to find in the docs but again was focused too deep in an app.

You don’t teach people a new spoken language by telling them everything about nouns, verds, and adjectives and 500 pages later maybe get around to a sentence. You would show them the sentence first, they wouldn’t know the exact details of connecting nouns to objects with prepositions but at least they could speak to each other and get started.

My ideal Flex example would build a simple app in a real world manner, first with states and containers, then add components, then data binding, then event delegation, finally styles, embedded assets, and transitions. All presented in a way that ties-everything-together.

Flex is an awesome tool but if people can’t find developers who know it and/or teach their current developers how to use it they’ll be turning to other free, *cough AJAX*, solutions.

*UPDATE*

I’ve found an awesome tutorial by Jesse Warden it uses cairngorm which can get pretty dense but Jesse comments everything in way that you can easily follow along, plus he gives a good overview of the app in his post before you even start looking at the code.

Digg! submit Flex Example Apps to stumbleupon.com submit Flex Example Apps to del.icio.us submit Flex Example Apps to reddit.com Like this post? subscribe to the feed.

October 5, 2006

The Ruby on Rails Rich Internet Application Software Development Kit by Adobe

Or RoRRIASDK, say that ten times fast!

The kit features six examples - and growing - of Flex/Fash with Ruby on Rails goodness including my Flash Remoting with Rails MP3 player tutorial. Big Ups to Mike Potter of Adobe for setting up the SDK and allowing me to contribute to it.

There’s also an Adobe PHP SDK if you’re so inclined.

Digg! submit The Ruby on Rails Rich Internet Application Software Development Kit by Adobe to stumbleupon.com submit The Ruby on Rails Rich Internet Application Software Development Kit by Adobe to del.icio.us submit The Ruby on Rails Rich Internet Application Software Development Kit by Adobe to reddit.com Like this post? subscribe to the feed.
Older Posts »

Powered by WordPress