Amazon Enters the Grid-Computing Market

Posted by ryan
at 4:19 AM on Thursday, August 24, 2006



Amazon.com is quietly building an impressive stable of web services to handle every bit of your computing infrastructure. Yeah, that’s right, these aren’t tiny little consumer-oriented web services to get product information (though those exist as well). These are services to manage file storage, messaging and now computing.

Amazon’s EC2 – Elastic Cloud Service provides an on-demand computing infrastructure, accessible via an API as well as a set of command line tools. With the use of their Amazon Machine Images (AMI) you can define a set of applications and libraries that you want to make available (think of these as virtual machine images) and can start them up as needed. Amazon has a standard set of Linux-based images with MySQL, Apache etc… And to top it off you can use the S3 storage service to persist your data (subject to normal S3 fees – though the bandwidth between EC2 and S3 is free).

Pricing for EC2 is competitive, as usual – you can get the equivalent of a machine with 1.7Ghz Xeon CPU, 1.75GB of RAM, 160GB of local disk, and 250Mb/s bandwidth for $72/month. Yeah, wow.

Jesse has a nice writeup about the service and you can check out these docs to learn more as well:

Think of the possibilities – an on-demand fleet of dedicated, preconfigured Rails servers with infinite storage…

All that’s left now is for Amazon to develop a relational storage service, perhaps built on top of S3 that can provide a standard SQL interface to your data. Then you will have the complete stack of services necessary to build most any application.

tags: , , ,

What's New in Edge Rails: Build URLs in Your ActionMailers (and other non-controllers)

Posted by ryan
at 5:03 PM on Wednesday, August 23, 2006



For a long time there was no good way to generate a URL within an ActionMailer. If you wanted to send a registration email when a user signs up for your application you would have had to pass in the url to be included in the email:


class MyController < ApplicationController
  def register
    # .. registration logic ...
    UserMailer.deliver_registration(user, home_url)
  end
end

class UserMailer < ActionMailer::Base
  def registration(user, url)
    @body = { 'user' => user, 'home' => url }
  end
end

This is hardly a hack, but it’s not as nice as it could be. It would be nice if the mailer itself could generate the url – or perhaps if the email template itself could generate the url? That day has come with the new ActionController::UrlWriter module.

Just include ActionController::UrlWriter in your mailer and you get access to all the familiar url_for and even the named url methods (home_url in this example):


class UserMailer < ActionMailer::Base
  include ActionController::UrlWriter
  def registration(user)
    @body = { 'user' => user, 'home' => home_url }
  end
end

tags: , ,

Streamlined UI Getting Slammed (you can help...) 0

Posted by ryan
at 6:04 AM on Thursday, August 17, 2006



There’s a post about Streamlined (aforementioned on this very site) over on the Rails blog that’s generating quite a few complaints. Some are misunderstandings about the capabilities of the framework itself (which can be remedied by more complete documentation) but the majority are about the poor visual design. Let me reiterate that the Streamlined guys are well aware of this deficiency and realize it’s something that must be fixed for wider adoption. In fact, they’ve made an open call (at RailsConf I believe) for designers to help them out in the matter.

So, if you’re more of a do-er than a whiner, get in touch with them to help out. (and nobody likes a whiner)

tags: , , ,

What's New in Edge Rails: Deprecated Finders

Posted by ryan
at 4:50 AM on Thursday, August 17, 2006



Those finder methods that have been marked for deprecation have now been formally deprecated using the nifty deprecation feature recently added to edge Rails. So, if you currently use any one of:

  • find_on_conditions
  • find_first
  • find_all

be prepared to get a little slap on the hand in the form of an error message: Your application calls ActiveRecord::Base##find_XXX, which is now deprecated. Please see the API documents at http://api.rubyonrails.org/ for more information.

Shame on you.

On a related note – using push_with_attributes is also deprecated. Use has_many :through instead.

tags: ,

In The Works - An Official Rails Plugin Repository

Posted by ryan
at 4:39 AM on Thursday, August 17, 2006



See Luke’s official announcement of the initiative

This isn’t something that’s new to Rails, the framework, but since it’s living within the official Rails repository, I feel compelled to represent.

Looks like there’s an official Rails plugins repository in the works. Judging from comments on one of my previous posts, the community definitely recognizes this as a need. (What, the plugins wiki not good enough?) It’s good to see some effort being placed into the organization of the larger Rails eco-system, and not just Rails itself.

On a side note, what’s that other little ditty in the application path of the repository? Molecule, a RESTful blogging app?

Do tell, David, do tell…

tags: , ,

Streamlined Framework: Domain Model Administration... for free

Posted by ryan
at 4:49 PM on Tuesday, August 15, 2006



I’m sitting in the middle of the Relevance guys’ presentation on the Streamlined Framework for the Raleigh Ruby Brigade right now – and I’m intrigued.

Most people have caught wind of Streamlined’s recent release but, if you’re anything like me, you haven’t really had a chance to dig into it or really understand what it’s about. Just so you hear it from another angle, here’s my take: Streamlined provides generation of domain administration views with strong support for the recognition of intra-model relationships. Tada.

Running script/generate streamlined user roles permissions gets you a rich administration portal that lets you browse/edit/query your user, roles and permissions models – and does so in a way that recognizes your domain model’s associations. If your appetite has been appropriately wetted (is that a word?), check out their screencast.

If you have visions of wading through streamlined’s generated views to customize and update options, fear not. Streamlined represents rendered views as a model class – i.e. UserUI for the User model etc.. This means that this code:

class UserUI < Streamlined::UI
  # Don't display the user's password in the view, but do
  # display their id
  user_columns :excludes => [:password], :includes => [:id]
end

Is all you have to do to adjust how Streamlined renders the user management view. (Obviously, there are several more options available…) The beauty in this is that this UI model is much less fragile to future upgrades, is very concise and just feels right. This is the part of Streamlined that excites me most.

Streamlined is an impressive solution to the problem of CRUD-based domain administration.

Streamlined, check it out.

And there’s an open call for designers to help out with the styling of the app – it’s a definite need so pitch in if you can

tags: , , ,

Ahhhh, Typo 4 Installed

Posted by ryan
at 1:52 PM on Thursday, August 03, 2006



If you’re reading this it means that Typo 4 was successfully installed. The other clue? The generic scribbish theme that everybody in the world on Typo 4 is using. (Scribbish no more, thanks David!)

I think we need another typogarden effort, maybe typo4garden?

The typo themes viewer is helpful – but doesn’t really address version compatability.

What's New in Edge Rails: Simply RESTful Support - And How to Use It

Posted by ryan
at 8:40 AM on Tuesday, August 01, 2006



See here from some syntactical changes that occurred after this post was published

Though I’ve been beaten to the punch on this one, it’s still worth a mention. Edge rails now has native support for the simply resful plugin functionality (though the implementation is not backwards-compatible as it now uses pluralized naming conventions in its mappings).

This addition continues the Rails march towards REST-vana and allows for easy declaration of REST-able controller methods. Where as edge Rails’s new Active Resource library provides the client-side part of the REST equation, simply RESTful provides the server-side handling of REST-based requests.

Basic Usage

The way it works is that you get a new map.resources method to use in your routes.rb config file that specifies which resource you want to RESTize. For example, assuming I have a standard users_controller I would add the following to my routes:

map.resources :users

Yeah, that’s it. And with that declaration, here are the requests that are mapped for me (all to the users controller):

GET: /users => [:action => 'index']
GET: /users.xml => [:action => 'index', :format => 'xml']
GET: /users/1 => [:action => 'show', :id => 1]
GET: /users/1;edit => [:action => 'edit', :id => 1]
GET: /users/1.xml => [:action => 'show', :id => 1, :format => 'xml']

POST: /users => [:action => 'create']
PUT: /users/1 => [:action => 'update', :id => 1]
DELETE: /users/1 => [:action => 'destroy', :id => 1]

Note that in true REST form, this one URL: /users/1 serves four different actions depending on request method (GET => show, POST => create, etc…). Beauty in simplicity…

It should be noted that Rails has to cheat to emulate the various HTTP request methods as most browsers don’t support sending PUT or DELETE requests. Rails does this by using the _method parameter in the various link_to helper methods

Advanced Usage

So REST is great for calling simple CRUD actions, but how do you invoke other actions while not stepping outside the friendly confines of the REST world? As was hinted at in the edit mapping above, you use the ‘;’ delimiter to denote a different action – along with telling map.resources what HTTP methods to use for the non-standard actions.


# Provided as default resource mappings
GET: /users/1;edit => [:action => 'edit', :id => 1]
GET: /users/1.xml;edit => [:action => 'edit', :id => 1, :format => 'xml']

# Update routes to handle non-standard CRUD actions
# This one says that a GET on 'filter' is accessing the collection
map.resources :users, :collection => { :filter => :get }

GET: /users;filter => [:action => 'filter']
GET: /users;filter?active=true => [:action => 'filter', :active => 'true']

# And this says that a POST to 'deactivate' is accessing a member item
# (i.e. a single item)
map.resources :users, :member => { :deactivate => :post }

POST: /users/1;deactivate => [:action => 'deactivate', :id => 1]

# Get funky and allow a PUT to 'new;admin'
map.resources :users, :new => { :admin => :put }

PUT: /users/new;admin => [:action => 'admin']

Hopefully this makes it pretty clear how you can layer your application functionality on top of this new RESTful routing. And for those looking for a real wow factor…

Wow Usage (i.e. Nested & Prefixed Routes)

...you can also specify path prefixes to your routes for trully spectacular routes:


# Give my user routes a prefix by group
map.resources :users, :path_prefix => "/groups/:group_id" 

GET: /groups/13/users/1 => [:controller => 'users', :action => 'show',
        :group_id => 13, :id => 1]

Another way you can achieve this nested routing is by nesting the resource mappings themselves


# Make both groups and users RESTable, with users as nested resources of groups
map.resources :groups do |group|
  group.resources :users
end

GET: /groups/13/users/1 => [:controller => 'users', :action => 'show',
      :group_id => 13, :id => 1]
GET: /users/1 => [:controller => 'users', :action => 'show', :id => 1]
GET: /groups/1 => [:controller => 'groups', :action => 'show', :id => 1]

Tidbits

With each resource mapping you specify, you also get a handy named route. So with:

map.resources :users, :collection => { :filter => :get }

You get a filter_users_url helper method:

filter_users_url #=> "/users;filter"

Don’t like the default naming? Fine, add your own prefix to the generated url name:

map.resources :users, :collection => { :filter => :get }, :name_prefix => 'my_'

Now:

my_filter_users_url #=> "/users;filter"

I think I’m in love.


tags: , , ,