Activate your free membership today | Log-in

Tuesday, June 24th, 2008

Clientperf: Simple Client-Side Rails Performance

Category: Performance, Rails

Eric Falcao has released Clientperf, a simple client-side Rails performance plugin.

The tool came about as Eric is giving a talk on “14 rules of high-performance websites in the typical rails mongrel/nginx stack, the main idea being to focus on some of the important implementation details when it comes to client-side performance optimization.”

As I was planning, I realized that there was no simple as in the we’re-all-spoiled-with-rails simple way to measure client download times in production. Now, there is clientperf. It’s just a start, but decent enough to benchmark the actual client performance impact of any optimizations you make.

How it works

It injects javascript into the page that takes a timestamp at the top of the page and at the bottom of the page. Once the browser is done downloading, evaluating and rendering all assets, clientperf makes one last image request to your server with the start time, end time and the URL. Piece of cake.

Rails Client Performance

Posted by Dion Almaer at 7:08 am
1 Comment

++++-
4.4 rating from 7 votes

Wednesday, March 12th, 2008

RadRails 1.0 Released

Category: Announcements, Aptana, Rails, Screencast

Aptana took over the RadRails open source project a few months back, and now have fully integrated it with Aptana Studio with the RadRails 1.0 release.

RadRails 1.0 runs as a plug-in to Aptana Studio. So in addition to all the Ruby on Rails IDE goodies and the integrated Rails shell command-line console, developers get the great HTML, CSS, DOM, JavaScript and Ajax features in Aptana Studio, which can run stand alone or within Eclipse to that all your other Eclipse tools can be right there as well.

The new version has a slew of new and enhanced functionality such as:

  • Rails 2.0 support
  • JRuby support
  • Bundled auto-installing gems for rails development
  • A Ruby profiler for Pro users
  • An RDoc preview view
  • Extended RHTML/ERb color preferences
  • Code completion for ActiveRecord model fields and finders
  • Code completion suggesting method call arguments
  • Significant expansion of code warnings and analysis, including syntax changes from Ruby 1.8 to 1.9
  • An improved look and feel

You can watch a screencast of the product at work or a full feature list.

Aptana continues to add new functionality to its products as it tries to hit the “best tools for Web development with scripting languages” vision.

Posted by Dion Almaer at 10:07 am
Comment here

++++-
4.5 rating from 13 votes

Sunday, February 10th, 2008

Heroku: Web based Rails Hosting

Category: Prototype, Rails, Ruby, Showcase

Heroku is a new YCombinator startup that joins the growing number of “use your browser to build your apps” type of applications.

You can create new Rails applications, and they are magically hosted up in the cloud. You can import your own Rails application, or you can use the inline editor and tools to built the application directly in the browser.

Heroku itself is a Rails application. I wonder if they now self hosting :)

Being able to quickly build an application and have it running live is great (using Amazon EC2), and this is just the beginning. They already tie into the usual tools like Rake, but there is room to go further and have nice DB utilities, cloning of functionality, and much more.

The editor itself could use a bunch of work too. I can never see where the cursor is, let alone have all of the Textmate / Aptana / IntelliJ goodness.

Heroku

Posted by Dion Almaer at 9:28 am
6 Comments

+++--
3.2 rating from 26 votes

Wednesday, January 30th, 2008

Rhino on Rails: JavaScript MVC on the server

Category: Framework, Java, JavaScript, Rails

Cross posted from my personal blog

Last week we posted about Jaxer which offers an approach of turtles all the way down where JavaScript is used on the client and the server.

Then, I got to interview Steve Yegge. Last year, Steve posted about Rhino on Rails, his port of Ruby on Rails to the JavaScript language on the Rhino runtime.

Ever since he presented on the ‘Google Rails Clone’ at FooCamp and he posted about the internal Google Rhino on Rails project, people have been curious to learn more.

  • What does it mean to port Rails to JavaScript?
  • What can’t you do since JavaScript doesn’t have the same meta programming facilities?
  • Rails = a group of Active*, so did you re-implement everything?
  • What do you gain out of having JavaScript all the way down?
  • Does it actually make sense to have jjs? Server side JavaScript generating client side JavaScript? Argh!
  • What is the state of Rhino?
  • Will Rhino support JavaScript 2?

And of course, the big questions:

When do I get to see it!

I happen to be in Seattle at the Google offices, so I was able to ask all of these questions and more. Steve was a fantastic host, and I really enjoyed chatting with him.

This is the kind of video I want to explore at Google. We have many great developers working on cool technology. I want to get them on camera, participating with the community when I can. Sometimes we can talk about products and APIs, but sometimes we will talk about fun ideas and projects that we are working on such as Rhino on Rails.

Anyway, give it a watch and let me know what you think:

This also lead me to the fun idea of Java and JavaScript flip-flopping:

Posted by Dion Almaer at 8:20 am
12 Comments

++++-
4 rating from 31 votes

Lipsiadmin: Rails 2.0 Ext Admin

Category: Ext, Rails

Lipsiadmin is a framework that generates Ext 2.0 views on top of your Rails 2.0 application, a compelling duo indeed.

You can strap into your migrations to add menus such as:

RUBY:
    # I will create also my menu
    menu = Menu.create(:name => "Articles", :admin => true, :position => 1)
    # And my
    menu.menuitems.create(:name => "New Article", :url => "/admin/articles/new",
      :position => 1, :style => "icon-no-group")
    menu.menuitems.create(:name => "List Articles", :url => "/admin/articles/list",
      :position => 1, :style => "icon-show-all")

If you stay in REST land it all just starts to work. Very Naked Objects-esque.

Check out the live demo (u: info@lipsiasoft.com, p: admin).

Speaking of Ext, the team has been expanded its offerings.

Posted by Dion Almaer at 5:47 am
6 Comments

++++-
4.3 rating from 35 votes

Wednesday, January 23rd, 2008

Ext Scaffold Generator Plugin for Rails

Category: Examples, Ext, Rails, Ruby

Martin Rehfeld has released a Rails plugin that generates Ext JS scaffolds

The Ext Scaffold Generator Plugin provides a custom MIME type alias :ext_json to be able to handle requests from the Ext frontend separately. The generated controllers show how to do this.

To make data delivery to the Ext frontend easy, the plugin extends the Array and ActiveRecord::Base classes to provide a to_ext_json method. Here’s a simplified example of a potential index method in a PostsController:

RUBY:
    # GET /posts
    # GET /posts.ext_json
    def index
      respond_to do |format|
        format.html     # index.html.erb (will fire ext_json request)
        format.ext_json { render :json => Post.find(:all).to_ext_json }
      end
    end

He also has some other good articles on integrating Ext JS and Rails in general.

Posted by Dion Almaer at 6:54 am
2 Comments

+++--
3.9 rating from 24 votes

Wednesday, January 9th, 2008

Tastebook: Rails Ajax Cookbook App

Category: Ajax, Flash, Rails, Showcase

I was at the PCWorld innovative product awards at CES last night, and ran into Tastebook, a site that allows you to build a personal cookbook from both online and your grandma's recipes.

The site is Rails based, and uses a mixture of JavaScript and Flash to get rich functionality such as a visual representation of the book, a designers, access to Web services, and drag and drop support.

Posted by Dion Almaer at 8:14 am
2 Comments

+++--
3.7 rating from 13 votes

Friday, January 4th, 2008

Zed Shaw interview on Rails community, enterprise, Ajax, patents, and a whole lot more

Category: Podcasts, Rails, Ruby

Rob Sanheim sat down with Zed Shaw at RailsConf and had an hour long conversation with him that covered his thoughts on the Rails community, the role of the Enterprise, the state of Ajax, JRuby and Rubinius, documentation, tests, tooling, the role of patents in software, and a whole lot of opinion.

Zed Shaw

It is very interesting to listen to this after the explosion that happened when Zed lambasted the Rails community. When you listen to this interview, you see some of the seeds of the rant, but it is a lot more toned down, and there is some good stuff in there. It is easy to blog a crazy rant.... but when you are talking to someone you get a different side of the coin. This gives you that side, from a time when he wasn't as upset as he may have been when he sat at the computer to type up his post.

Listen to the recording, or subscribe to the podcast. We will go back to more "standard" Ajax topics in the future.

Zed's Core Quotes

  • On Semantic Web: Einsteins brain on a crack whores body isn't going to happen
  • I'm waiting for someone to blind-side the entire Web stack
  • Some people hate me, but love Mongrel
  • Where is the XP for managers

And here are some of the thoughts that Zed expressed throughout the interview:

Thoughts on the Rails community, and enterprise (as big business)

  • Mixed feelings
  • Mongrel was an art project
  • Simpler software is better
  • Enterprise software is known to be complex, and survives to make money for consulting companies
  • Afraid of consulting companies getting behind it, as their interest is in selling 30 people vs. 3 people teams

What could an enterprise company sell?

  • Do enterprise stuff well such as Authentication
  • Stacks: Make it simple (no ClassLoader6)

JRuby

  • It is a huge deal
  • The only fear is that Sun will mess it up with the JCP.
  • The JRuby guys are rock stars

Rubinius

  • An open source project not controlled by anyone
  • A bunch of guys who really love Ruby
  • Massive "spec", working with the JRuby guys

State of Ajax

  • HTTP sucks
  • Needs to be a reset
  • Semantic Web: "Einsteins brain on a crack whores body isn't going to happen"
  • I'm waiting for someone to blind-side the entire Web stack
  • Ajax the technology doesn't impress me, but the new UIs that we are seeing is fantastic
  • Usability != better looking
  • "click here" actually does a really good job at having people click here!

What is going to come out with all of the work happening on top of Mongrel?

  • Swiftapply
  • Evented mongrel
  • DrProxy
  • OpenBSD clustering
  • X hits per day is meaningless. What is the peak?

Honest Open Source

  • Not all open source projects are equal
  • Make everything open and public immediately (e.g. SVN)
  • Corporate open source projects often lose their flavour
  • Outside commiters are key
  • Some people hate me, but love Mongrel
  • Documentation is poor for Rails and Ruby, Ruby doesn't have a culture for it
  • Rails core does a much better job that the Ruby community in general, and this is a reason why it took off
  • QRI command line. Way better than RI
  • If Rails core isn't using it, don't use it. Add: used_by

What tools do you use?

  • Vim
  • Use a generic tool, and pimp it
  • "I code with a thesaurus"
  • Vim is designed to be used on phone lines, and it is very safe
  • Good tools never cover your code

Testing

  • A bit of design up front
  • Design the API
  • Tests to measure how it is working
  • Quality comes from the design ahead of time

Posted by Dion Almaer at 7:55 pm
5 Comments

+++--
3 rating from 58 votes

Thursday, October 18th, 2007

PackR: Rails Packing

Category: JavaScript, Rails, Utility

James Coglan has produced a Rails plugin to handle Dean Edwards Packer.

PackR allows you to programatically compress:

RUBY:
    # Create a new instance of Packr first
    packr = Packr.new
    compressed = packr.pack(script)

    # Pass options to control the type of compression
    compressed = packr.pack(script, :shrink_vars => true)
    compressed = packr.pack(script, :base62 => true)
    compressed = packr.pack(script, :shrink_vars => true, :base62 => true)

or you can use the rake task:

rake packr:pack_libs

Posted by Dion Almaer at 6:26 am
7 Comments

++---
2.2 rating from 29 votes

Monday, October 1st, 2007

Sass-y Dynamic CSS

Category: CSS, Library, Rails

Geoffrey Grosenbach gets all funky when he discusses dynamic CSS using the Sass engine that comes with HAML.

It allows you to:

Nesting

If you are sick of repeating yourself, you can get dry and nest your code:

Variables

You can set variables with !

CSS:
  1.  
  2. !note_bg= #55aaff
  3.  
  4.   #main
  5.     :width 70%
  6.     .note
  7.       :background-color= !note_bg
  8.     p
  9.       :width 5em
  10.       :background-color= !note_bg
  11.  

and even do math on the color variables:

CSS:
  1.  
  2. !pink = #ff43a7
  3. !darker_pink = !pink - #333333
  4.  

Imports

You can also split up your work and @import foo.css to combine everything into one file for production, including the ability to share variables.

Play around with it by tinkering with their live online lab

Posted by Dion Almaer at 4:40 am
14 Comments

++---
2.6 rating from 23 votes

Wednesday, July 11th, 2007

Uncluttr: A cleaner Amazon

Category: Prototype, Rails, Showcase

Derek Gaw gave an ignite talk tonight onAIR which showed off his Uncluttr project.

Derek works for Amazon, but this is outside of his company work. He is frustrated seeing 1.5MB of content being downloaded when you login, find a book, and then view the detail page. That is too much.

Uncluttr uses the Amazon Web Services and is written with Prototype and Rails.

Uncluttr

Posted by Dion Almaer at 12:01 am
11 Comments

+++--
3.8 rating from 32 votes

Friday, July 6th, 2007

5 Ways to Optimize Ajax in Ruby on Rails

Category: Articles, Rails

You’re understandably proud of your latest fancy Ajax interface, but is it wasting your app’s precious resources? In this article on Think Vitamin, Shanti Braford shows you five ways to make sure your Ajax is optimized.

He goes into detail on:

  1. Optimal Database Indexing
  2. Eliminate Redundant SQL Queries
  3. Fragment Caching
  4. Response Text Compression/Minimization
  5. Pre-rendering and Client-side JavaScript Caching

You will note that most of these have little to do with Ajax, and are general advice. It gets interesting on:

5. Client-side JavaScript Caching and Pre-rendering

If you really want to wow your users, pre-cache commonly called AJAX components into hidden divs so that the only time necessary to load them is the time it takes their browser to execute (eval) the pre-rendered JavaScript.

In the following example, we’ll cache conversations into hidden divs so that whenever a user clicks on a conversation, it’ll load almost instantaneously.

The pre-caching functions will all access a single global JavaScript variable that holds an array. That array will be populated on the first page load with the conversation IDs that should be cached.

Posted by Dion Almaer at 5:20 am
2 Comments

+++--
3.4 rating from 20 votes

Saturday, May 19th, 2007

RailsConf 2007 - Day 1

Category: Conferences, Rails, Ruby

RailsConf is underway in Portland, Oregon, and day one (Friday) is in the bag. The keynote by DHH covered what to expect from Rails 2.0. Front and center was an emphasis on RESTful development, which should come as no surprise to anyone who has followed Rails lately. The big takeaway for ajax developers is that Rails will let you return javascript seamlessly for any request, right along side the same code you use for a standard HTTP requests, or XML requests, or whatever. This ultimately means more cohesive, cleaner code in your controllers, and that adding ajax is as easy as adding a format.js to serve XHR requests:

RUBY:
    class PeopleController <ApplicationController
      ...
      def create
        @person = Person.create(...)
        respond_to do |format|
          format.html { redirect_to person_url(@person) }
          format.xml  { render :status => :created, :location => person_url(@person), ... }
          format.js   {
            render :update do |js|
              ... # RJS code here to update the page with js with your created person
            end
          }
        end
      end
    end

Rails 2.0 also has some great optimizations coming for HTTP performance. If you've ever looked at the size of prototype+scriptaculous (or dojo, or yui, or...), plus your own custom scripts, PLUS the overhead of the HTTP connections for each seperate javascript file, you know that page load time can get horrendous really quick. The upcoming version will allow easy batching of your js and css, and automatic gzipp'ing when in production, using the standard javascript/stylesheet include tags:

RUBY:
    <%= javascript_include_tag :all, :cache => true %>
    <%= stylesheet_link_tag :all, :cache => true %>

One other quick win Rails 2.0 will give you is multiple hosts for assets. Browsers will only have two concurrent connections open for any single host, but an easy way around that is to use multiple subdomains that resolve to the same domain. So if you set:

RUBY:
    config.action_controller.asset_host = 'static%d.example.com'

Your rails app will randomly choose static01, static02, etc...to get more parallel connections for static assets. This assumes you use the built in img, js, and css helpers, of course.

For more full coverage of the keynote in core-Rails areas, see Nick's notes.

The other ajax-centered session for the day was on full web stack testing with Selenium Remote Control, by Alex Chaffee and Brian Takita (PDF here). The ajax testing story is still a mixed bag, with a lot of different tools and approaches and not one clear best path. Selenium RC lets you test at the function level of your JS, all the way to a functional level of forms and events, all in the language your app is written in (hence the "remote control" part). For more details see the Selenium link above or the detailed pdf for all the code.

Posted by Rob Sanheim at 5:03 pm
10 Comments

++++-
4.2 rating from 20 votes

Friday, May 11th, 2007

ActiveScaffold

Category: Rails, Showcase

Richard White has created another Rails Ajax Scaffolding solution with the ActiveScaffold plugin:

ActiveScaffold provides you with a wealth of dynamically created goodness:

  • An AJAXified table interface for creating, updating, and deleting objects
  • Automatic handling of ActiveRecord associations
  • Sorting, Search and Pagination
  • Graceful JavaScript degradation
  • RESTful API support (XML/YAML/JSON) baked in
  • Sexy CSS styling and theming support
  • More extension points than you can shake a stick at
  • Guaranteed to work on Firefox 1+, IE 6+ and Safari 2+
  • Released under the MIT License, the same one as Rails itself, so you can use it freely in your commercial applications.

Check out the set of demos to see it at work:

ActiveScaffold

Posted by Dion Almaer at 12:49 am
11 Comments

+++--
3.8 rating from 43 votes

Tuesday, April 24th, 2007

Aptana Ajax IDE: Brings together RDT and RadRails

Category: Aptana, Rails

Aptana made news when they brought in RadRails, and now they have consolidated their Ruby support by announcing the incorporation of the Ruby Development Team project into the Aptana IDE:

The Aptana IDE is targeted at AJAX (Asynchronous JavaScript and XML) style development and provides support for JavaScript, CSS (Cascading Style Sheets) and HTML and is fully integrated with FireBug for JavaScript debugging. The Aptana IDE is cross-platform, open-source, and free; with the addition and integration of RadRails and RDT, the Aptana IDE will make "Ajax on Rails" a reality, company officials said.

I have been trying out Coda on the Mac, and it is pretty nice for mainstream Web development.

Posted by Dion Almaer at 7:00 am
4 Comments

+++--
3.5 rating from 17 votes

Tuesday, March 27th, 2007

CrowdRules

Category: Rails, Showcase

CrowdRules is a Ruby on Rails website that lets the community rank videos.

Igal Koshevoy told us about the new site that is in beta:

CrowdRules is a "crowd-powered content recommendation engine". We use Ajax in a few, carefully-selected parts of our application to improve the user experience. Our application is written using Ruby on Rails and implements Ajax features using RJS templates and the Prototype library. These tools are a pleasure to work with and make it easy to get things done right, so we highly recommend them.

Here are some of the highlights of our use of Ajax:

Votes and violations: CrowdRules strives to provide a honest voting environment for our users. The application prevents common abuses of online voting systems by encrypting votes using one-time tokens. Ruby on Rails lets us elegantly bind the voting UI with the logic that manages tokens and thus votes. In the past, using AJAX meant struggling with parameter parsing and writing screenfuls of JavaScript that often duplicated application logic or required a bunch of stubs to interact with the underlying application. But Rails lets us implement the voting features without any of that fuss. Using Ajaxified Rails helpers, like "link_to_remote", the user clicks are cleanly routed to our controller for processing and then onto an RJS template that generates JavaScript to update the UI. The resulting code is surprisingly easy to read and maintain. The same pattern is used to let users report violations such as "this video doesn't play".

Video creation: CrowdRules tries to make it easy for users to add exciting content. We use AJAX to save users from having to fill out long forms that specify the video's name, embed HTML and such. Instead, our users simply paste a video's URL into a form that invokes an Ajax-enabled action that parses it, identifies the media provider (e.g. YouTube) and uses that provider's API to return a pre-populated form automagically. The form only displays fields the user needs to fill out, which vary depending on whether the video was found, was already in our system, what provider serves it, etc. When the user submits the form, all fields are validated against rules unique to that state and this prevents broken submissions by making sure that the embed HTML matches an actual video at the media provider, that the entry has a title and so forth. The combination of AJAX bindings, Prototype, and Rails features like ActiveRecord validations let us make this friendly form quickly.

Unit tests: It's important for Crowdrules that our application works correctly, but this can be a challenge for a rapidly-growing application that we're always adding features to and even a small change can inadvertently break the system. To address this, we've built an automated test suite that validates almost all of our application's features. AJAX is tricky to test, but we've made the AJAXified actions fall back to traditional behavior when JavaScript isn't available, such as during tests. For example, one test submits a valid vote to an AJAX-enabled action via a faux web browser and then confirms that all the proper database entries were made -- and we also have another battery of tests that cast all sorts of invalid votes and make sure that none of them make it into the database. Being able to validate the logic invoked by the AJAX actions by applying these approaches has made development much easier and less risky.

CrowdRules

Posted by Dion Almaer at 4:11 am
18 Comments

+++--
3.5 rating from 24 votes

Next Page »