RSS Slash Dot Dash

http://www.slashdotdash.net

Rolling on Rails

Last checked 42 minutes ago.

22 people have subscribed to this feed.

This feed is part of ben's lifestream.

Feed frequency

post frequency (last month)

PostRank™ filter

latest 15 posts

« older items




Friday September 19th, 2008

1.2

Easy Merb installation using Thor

From Slash Dot Dash, 22 days ago, 0 comments Comment

There’s now a much simpler way to get Merb setup than I previously noted. By using Thor, either the Stable (Gem) or Edge releases of Merb can be installed as a local Ruby Gem or bundled with your Merb app.

The thor tasks are context aware. Run them in a Merb application directory and they’ll bundle the relevant files with your app; keeping dependencies with the application and making it independent of your system’s Ruby Gems. When run outside any application, they target the system in general (installing as a standard Gem). This is determined by the presence of a local gems directory (or by specifying the --merb-root option).

Installing Edge Merb and DataMapper

mkdir merb; cd merb

# Install Thor
sudo gem install thor

# Get merb.thor file (or update existing file)
curl -L http://merbivore.com/merb.thor > merb.thor
thor merb:tasks:update

# Merb (edge)
sudo thor merb:edge:core --install
sudo thor merb:edge:more --install
sudo thor merb:edge:plugins --install

# DataMapper
sudo thor merb:edge:dm_core --install
sudo thor merb:edge:dm_more --install

Keeping updated with the latest Merb (merb-core and merb-more only) is now simply:

sudo thor merb:edge --install

Further details are given on the merbunity site.

Saturday July 5th, 2008

7.6

Getting started with Merb and Datamapper

From Slash Dot Dash, 3 months ago, 0 comments Comment

Merb is the up-and-coming Ruby web framework, designed to improve upon the ideas in Rails whilst being faster, lighter and less opinionated (or more agnostic). I wanted to discover whether it provides any benefits over Rails and what it does differently. The best way to find out; get it installed it and create a new app.

The official Merb website gives the following simple installation instructions.

sudo gem install merb

However, since I wanted to also try DataMapper as the ORM those instructions failed to install a working setup due to a conflict between Merb and DataMapper dependencies. Unperturbed, I finally got them both installed and working happily together by getting the bleeding edge code from each project’s github repository and following the instructions provided by Mathew Ford’s Living life on the edge. The book is also available on github, you can contribute patches there. Hopefully this issue will be resolved soon enough so that you’ll be able to install the official release gems for both Merb and DataMapper from Rubyforge (instead of running on edge).

Prerequisites

  • You must have git installed (sudo port install git-core using MacPorts on OS X).
  • Remove any older versions of merb (and datamapper) that you might have installed. Use gem list to view local gems and sudo gem uninstall <name> to remove each individual gem.

The Easy Way

Matt’s book outlines an easy way of installing the latest merb & datamapper source, however it failed to properly install the DataMapper gem for me so I had to resort to the hardcore approach.

sudo gem install sake
sake -i 'http://edgy.4ninjas.org/edgy.sake'
sake edgy:install packages="merb-stack"

After installing, to keep up-to-date you just need to execute:

sake edgy:update

Now, if you’re hardcore…

Installing the required dependencies

Start by installing the gem dependancies.

sudo gem install rack mongrel json erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory ruby2ruby

Installing Merb

Download the merb source:

git clone git://github.com/wycats/merb-core.git
git clone git://github.com/wycats/merb-plugins.git
git clone git://github.com/wycats/merb-more.git

Then install the gems via rake:

cd merb-core ; rake install ; cd ..
cd merb-more ; rake install ; cd ..
cd merb-plugins; rake install ; cd ..

Installing DataMapper

git clone git://github.com/sam/extlib.git  
git clone git://github.com/sam/do.git

cd extlib ; rake install ; cd ..
cd do
cd data_objects ; rake install ; cd ..
cd do_mysql ; rake install ; cd ..
cd ..

git clone git://github.com/sam/dm-core.git
git clone git://github.com/sam/dm-more.git

cd dm-core ; rake install ; cd ..
cd dm-more ; rake install ; cd ..

Keeping updated

To update your local gems with the latest code changes you’ll need to do a git pull and then rake install for each of the git repositories previously downloaded.

Creating your first Merb app

You create a new empty Merb app via the merb-gen utility.

merb-gen app demo
(You can also create flattened or single file applications if you wish).
merb-gen app app_name --flat      (for a flattened application)
merb-gen app app_name --very-flat (for a single file application)

As we’re using DataMapper we need to edit config/init.rb and uncomment the use_orm :datamapper line. The next step is to create the database settings file config/database.yml:

---
development: &defaults
  adapter:    mysql
  database:   demo_development
  username:   demo
  password:        p@ssword
  host:       localhost

test:
  <<:         *defaults
  database:   demo_test

production:
  <<:         *defaults
  database:   demo_production

You can now fire up the Merb server to make sure it runs.

$ merb
 ~ Loaded DEVELOPMENT Environment...
 ~ Connecting to database...
 ~ loading gem 'merb_datamapper' ...
 ~ Compiling routes...
 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
 ~ Using Mongrel adapter

Some other useful commands to know:

merb -i                                                        # Interactive merb console

merb-gen model <name>                            # Creates a Datamapper Model stub
merb-gen resource <name>                    # Creates a full resource (incuding model, controller, views & test spec)

rake dm:db:automigrate            # Perform automigration
rake dm:db:autoupgrade            # Perform non destructive automigration

Let’s see how it goes from here with Merb!

Wednesday March 12th, 2008

1.4

Lifestreaming - combining your online activity into a single stream (using trawlr)

From Slash Dot Dash, 7 months ago, 0 comments Comment

It’s been a year since I last mentioned trawlr on this blog at which point I promised no further status updates here. Well I’m going to just pretend I didn’t say that for now as I wanted to get some feedback (and usage) on the latest feature I’ve been working on.

Streaming your life away

It’s support for “lifestreaming” – combining your online identity from various different social sites into a single stream. Very much like a diary or timeline of events, grouped by date.

The inspiration for this feature came from a blog post by Jeremy Keith (hence the title) so props to him for the idea.

Lifestreaming is like Twitter, but covers everything you do online that is publicly available and has an RSS feed. Currently there’s support for Delicious, Flickr, Twitter, Upcoming, Last.fm, your own blog feed (RSS) and any other site that provides an RSS feed.

You can see an example of my lifestream in the screen shot. If you already have a trawlr.com account then why not give it a whirl and create your own lifestream. Don’t have an account yet? Registration is quick & simple (with no email activation required) and once you’ve tried out the lifestreaming, you might also be interested in the main RSS reader.

Once you’ve created your lifestream, it’ll be automatically updated throughout the day.

Let me know if you can think of any important sources I’ve missed, such as; YouTube, Picassa, SmugMug, FaceBook, MySpace, Google Reader shared items, Digg (dugg by) and Reddit (activity).

I’m planning to create a “widget” version of the lifestream so that it may be embedded within your own blog or website, allowing customisation of the display

Sunday March 9th, 2008

6.1

Sphinx search with delta indexing thanks to Ultrasphinx

From Slash Dot Dash, 7 months ago, 0 comments Comment

Evan Weaver has just announced delta indexing support for his UltraSphinx Rails plugin.

Delta indexing speeds up your updates by not reindexing the entire dataset every time.

First, in your .base file, set the indexer option delta to your maximum interval between full reindexes. A day or a week is good, depending. Add a little bit to account for the time it takes the actual index to run:

delta = <%= 1.day + 30.minutes %>

Now, configure your models for delta indexing in the is_indexed call:

is_indexed :fields => ['created_at', 'title', 'body'], :delta => true

Now you can run rake ultrasphinx:index:delta frequently, and only records that were changed within 1 day will be reindexed. You will need to run rake ultrasphinx:index:main once a day to move the delta contents into the main index.

From the UltraSphinx documentation.

I’ve previously written about how fast Sphinx search is in Rails searching with Sphinx using the acts_as_sphinx plugin (and also contributed a chapter to the Advanced Rails Recipes book using the UltraSphinx plugin). I’d now recommend using the UltraSphinx plugin if you want to take advantage of Sphinx for your Rails application.

In my opinion, this completes the ‘missing’ piece of functionality and should make Sphinx your default full-text search engine (if you’re using MySQL).

Saturday March 8th, 2008

6.9

Pimp my MacBook Pro

From Slash Dot Dash, 7 months ago, 0 comments Comment

Thanks to the increasing prevalence of Apple laptops – including the MacBook, MacBook Pro and new Air – having a Mac no longer makes you l33t! To combat this, a couple weeks ago I decided to pimp my MacBook Pro by changing the illuminated Apple logo on the case. A Canadian site sells a multitude of inserts that can be used to alter the logo.

Customize your laptop for only $4.99! These high-quality inserts will make your laptop one of a kind! Free Worldwide Shipping! Compatible with: iBooks, Powerbooks, MacBooks and MacBook Pros

The installation guide steps you through the process, the MacBook Pro is rated as “Medium” difficulty. Apart from the tight angle to unscrew the 2 retaining screws at the bottom of the screen, the tricky part to the process is removing the back of the screen using a credit card. You need a steady hand and a slightly cavalier attitude to prise the cover apart!

I went for the ‘Rainbow’ design – one of the original Apple logos – the end result is rather pleasant update to the plain white logo and it still glows in the dark.

6.4

BBC iPlayer on the iPhone

From Slash Dot Dash, 7 months ago, 0 comments Comment

Yesterday the BBC announced that their iPlayer video on demand service was available for the iPhone (and iPod Touch). There’s a more in depth post on the BBC Internet Blog where they give details on the technical implementation.

Back to BBC iPlayer on iPhone implementation: we’re not using the new Apple SDK, nor are we using the much-rumoured Flash for iPhone (no – we haven’t seen it, either). Instead, we’re creating 516Kbps streams (400Kbps H.264 video, 116Kbps AAC audio) that show off BBC programmes brilliantly on an iPhone.

It’s interesting to read about the raw processing power required to transcode their 24 simultaneous incoming programmes, for a peak data rate of over a gigabit per second of incoming video.

I tried out an episode of Top Gear and was impressed with both the streaming speed and the quality of the video (check out the images below). The only downside is that it only supports streaming and requires a WiFi connection; unsurprisingly, EDGE isn’t fast enough. Ideally it would be fantastic to be able to download a programme to watch ‘offline’, such as on a train (I’ll keep my finger’s crossed).

Thursday February 28th, 2008

1.5

Contributing to "Advanced Rails Recipes"

From Slash Dot Dash, 7 months ago, 0 comments Comment

The latest Beta update to the new Pragmatic Programmers book Advanced Rails Recipes: 72 New Ways to Build Stunning Rails Apps includes two chapters authored by myself.

They are both complete rewrites and updates of two of my popular blog posts Rails searching with Sphinx and iPhone on Rails – Creating an iPhone optimised version of your Rails site using iUI and Rails 2.

The new recipes are:

  • Full-Text Search with Sphinx – includes a Rails site that uses Sphinx to index the Rails API.

  • Support An iPhone Interface – with a TODO list app.

Along with these two (worth the purchase price on their own!), there are another 79 great recipes with some of the latest Rails best practices in small, easy to implement chunks.

Friday February 15th, 2008

5.8

Ruby Tidbit: Timeout code execution

From Slash Dot Dash, 7 months ago, 0 comments Comment

Just a small tip, if you wish to ensure a snippet of Ruby code doesn’t run for too long you can use the timeout function. You might want to do this when making a request to a remote server with net/http for example.

timeout.rb

A way of performing a potentially long-running operation in a thread, and terminating it‘s execution if it hasn‘t finished within fixed amount of time.

Here’s a quick example using the excellent rFeedParser (Universal Feed Parser in Ruby) to fetch an RSS feed.

require 'timeout'
require 'zlib'
require 'rubygems'
require 'rfeedparser'

fp = nil
begin
  # Don't take longer than 20 seconds to retrieve & parse an RSS feed
  Timeout::timeout(20) do
    fp = FeedParser.parse("http://feeds.feedburner.com/slashdotdash")
  end
rescue Timeout::Error
  # Too slow!!
end

Sunday January 27th, 2008

1.1

yabb.com - the art of conversation

From Slash Dot Dash, 8 months ago, 0 comments Comment

Thursday was the launch party for Cominded’s latest social application yabb. It’s currently still in private beta, although everyone who attended the event had the opportunity to register on the night and should have received an invitation the following day.

Paul Walsh was first off the mark to blog about yabb and followed up with an interview with Paul Birch. On Friday, Techcrunch UK (followed by US) wrote about the launch of yabb and there were further blog reactions. Oli Barrett at the Daily Networker wrote a great article about yabb titled ‘A Little More Conversation’.

yabb lets you talk more and type less by connecting you with people and topics you’re interested in

For those who haven’t yet joined yabb (with a lowercase y), it’s a social network that facilitate one-to-one conversations between like-minded people using Skype. With yabb we’re promoting the art of conversation; you find a topic you’re interested in, choose who you want to talk to and invite them to contact you using a call request.

Why not head along to register and keep up to date via the blog. If you’re already signed-up and using yabb then we’re very interested in getting your feedback and any ideas for new features.

Monday January 21st, 2008

1.2

London this week; Rails, free pizza & beer and Cominded de-stealth

From Slash Dot Dash, 8 months ago, 0 comments Comment

This Thursday, 24th Jan, is the latest Pizza on Rails event where you can enjoy free pizza & beer, meet-up with fellow Rails developers and find out what Cominded has been working on when we announce our exciting new Rails site.

Join the Pizza On Rails mailing list for further details and to RSVP to indicate your attendance. It looks like it’ll be another great night with almost 100 people already signed up.

Wednesday January 16th, 2008

6.9

Quick Tip: Watch movies on your iPhone - conversion from AVI files on Mac OS X

From Slash Dot Dash, 8 months ago, 0 comments Comment

Want to watch a movie on your iPhone (or iPod)? The simplest method of converting to the correct format and size is to use iSquint an “iPod video conversion app for Mac OS X”.

Install, then fire up the iSquint application. Drag & drop your .avi file onto the window. Select Optimize for iPod, Add to iTunes and H.264 Encoding. Set the Quality slider (I’d recommend High) and click Start.

Leave iSquint to do its stuff and you’ll have the converted film available in iTunes. For a single CD avi file, expect a final file size of around 300-350MB for High Quality or 150-200MB for Standard Quality settings (at 127kbps bit rate).

Note: You’ll need to manually select the movie for synching when your iPhone or iPod is connected to iTunes.

2.0

When did you start working with Rails?

From Slash Dot Dash, 8 months ago, 0 comments Comment

Got a copy of Agile Web Development With Rails
Wed 9th Nov, 2005
Order #: 202-0160452-2867026 (amazon)
Items: 1 x Agile Web Development with Rails
Purchased TextMate (and a Mac to run it on)!

Announced first Rails site
Sat, 29th Apr 2006
trawlr.com online rss agregator
Started working professionally with Rails
Mon, 5th November 2007
Cominded

Tuesday December 4th, 2007

10

iPhone on Rails - Creating an iPhone optimised version of your Rails site using iUI and Rails 2

From Slash Dot Dash, 10 months ago, 0 comments Comment

After upgrading trawlr.com to Rails 2 I thought I’d make use of some of the new features and attempt to create an iPhone version of the site. With Rails 2 you can create a mime type specifically for the iPhone and then use that format in a respond_to block (along with views such as index.iphone.erb).

Before you start – iPhoney

iPhoney is an indispensable Mac-only tool for aiding the development of an iPhone specific site.

Looking for a way to see how your web creations will look on iPhone? Look no further. iPhoney gives you a pixel-accurate web browsing environment—powered by Safari—that you can use when developing web sites for iPhone. It’s the perfect 320 by 480-pixel canvas for your iPhone development. And it’s free. iPhoney is not an iPhone simulator but instead is designed for web developers who want to create 320 by 480 (or 480 by 320) websites for use with iPhone. It gives you a canvas on which to test the visual quality of your designs.

Ensure iPhoney’s user agent is set to iPhone User Agent in the menu.

iPhone mime type

Create an iPhone mime type alias using Rails 2 initializers.

config/initializers/mime_types
Mime::Type.register_alias "text/html", :iphone
Detecting iPhone user agents

Apple recommends that rather than redirecting iPhone users to an iPhone-optimised version of your site you should instead show the original site with a link to the alternative.

This can be achieved via user agent sniffing; looking for Mobile Safari (as Apple suggests), rather that iPhone or iPod touch, to allow for future device support.

Adding a helper method to application_helper.rb allows a notification message to be shown for only iPhone users (try accessing www.trawlr.com from an iPhone).

app/helpers/application_helper.rb
# Request from an iPhone or iPod touch? (Mobile Safari user agent)
def iphone_user_agent?
  request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/]
end

In your view, show a message for iPhone user agents directing them to the iPhone version.

<% if iphone_user_agent? # Show message for iPhone users -%>
<div class="message">
    <p>Using an iPhone? <a href="http://iphone.trawlr.com/">Use the optimised version</a>.</p>
</div>
<% end -%>
iPhone subdomain

Instead of forcing users straight to our iPhone version, we offer them the option by using a separate subdomain (iphone.trawlr.com) with a link back to the regular site if they wish. When developing locally I modified my /etc/hosts file as follows so that I could use http://iphone.localhost.com:3000/.

/etc/hosts
127.0.0.1 iphone.localhost.com

You may need to flush the DNS cache after making the changes.

sudo dscacheutil -flushcache
Adjust format for iPhone

I chose to require login for all requests to the iPhone version of the site.

class ApplicationController < ActionController::Base
    before_filter :adjust_format_for_iphone
    before_filter :iphone_login_required

private

  # Set iPhone format if request to iphone.trawlr.com
  def adjust_format_for_iphone    
    request.format = :iphone if iphone_request?
  end

  # Force all iPhone users to login
  def iphone_login_required
    if iphone_request?
      redirect_to login_path unless logged_in?
    end
  end

  # Return true for requests to iphone.trawlr.com
  def iphone_request?
    return (request.subdomains.first == "iphone" || params[:format] == "iphone")
  end
end

Note that sessions_controller.rb (handles login) requires skip_before_filter :iphone_login_required.

Using iUI and creating iPhone views

The iUI framework, based on Joe Hewitt’s iPhone navigation work, hugely simplifies iPhone web development. All you need to do is include the iUI JavaScript and CSS files along with included images and create your views in a particular structure to have native iPhone behaviour such as sliding menus and AJAX page loading.

Rails 2 makes it trivial to create different views depending upon the format, including layouts. Our iPhone layout includes a few specifics for iUI and a viewport meta tag for the device.

app/views/layouts/application.iphone.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
    <title><%= @page_title -%></title>
  <%= stylesheet_link_tag 'iui' %>
  <%= javascript_include_tag 'iui' %>
</head>
<body>
    <div class="toolbar">
        <h1 id="pageTitle"></h1>
        <a id="backButton" class="button" href="#"></a>
    </div>

    <%= yield %>
</body>
</html>

When creating your iPhone views you should follow the iUI style guide, an example page is given below. Standard hyperlinks are loaded using AJAX and slide into view, navigating back is handled by iUI. Links may be prefixed with target="_self" to replace the entire page or target="_replace" to replace the element with the response (using AJAX).

index.iphone.erb
<ul title="Home" selected="true">
    <li><%= link_to 'Example action', example_path %></li>
    <li><%= link_to 'Logout', logout_path, :method => :delete, :target => '_self' %></li>
</ul>
show.iphone.erb
<div class="panel" title="Example" selected="true">
    <h2>Example Content</h2>
    <p>Here's some content</p>
</div>

It’s important to remember that iUI will load content using AJAX, thus you only need to render a layout (such as application.iphone.erb) for the first request or page of your iPhone site. All following requests should use render :layout => false (unless loaded into a new page with target="_replace"). If you experience any wierd rendering issues it’ll most likely be due to this irregularity.

respond_to do |format|
    format.iphone do  # action.iphone.erb
      render :layout => false
    end
end
Show, don’t tell

Why not try iphone.trawlr.com for yourself? It’ll work for your iPhone or any web browser. You’ll need to register via the normal site if you don’t already have an account (quick, no email registration required)!

References

The following resources on the new Rails 2 iPhone format ability and iUI library were extremely helpful; the documentation from Apple not so much!

http://developer.apple.com/iphone/ http://www.railspikes.com/2007/11/8/iphone-subdomains-with-rails http://blog.nicksieger.com/articles/2007/09/18/railsconf-europe-david-heinemeier-hansson http://www.joehewitt.com/blog/introducing_iui.php http://code.google.com/p/iui/

Yes, I’m still loving the iPhone!

Monday December 3rd, 2007

10

Rails 2 Upgrade Notes

From Slash Dot Dash, 10 months ago, 0 comments Comment

Over the weekend I decided to try out Rails 2 by upgrading an existing site (http://www.trawlr.com/) from Rails 1.2.6 to Rails 2 RC2.

Check for deprecations before you upgrade

You may want to check your existing application for deprecated code before upgrading using the following rake task.

lib/tasks/rails.rake
desc "Checks your app and gently warns you if you are using deprecated code." 
task :deprecated => :environment do
  deprecated = {
    '@params'    => 'Use params[] instead',
    '@session'   => 'Use session[] instead',
    '@flash'     => 'Use flash[] instead',
    '@request'   => 'Use request[] instead',
    '@env' => 'Use env[] instead',
    'find_all'   => 'Use find(:all) instead',
    'find_first' => 'Use find(:first) instead',
    'render_partial' => 'Use render :partial instead',
    'component'  => 'Use of components are frowned upon',
    'paginate'   => 'The default paginator is slow. Writing your own may be faster',
    'start_form_tag'   => 'Use form_for instead',
    'end_form_tag'   => 'Use form_for instead',
    ':post => true'   => 'Use :method => :post instead'
  }

  deprecated.each do |key, warning|
    puts '--> ' + key
    output = `cd '#{File.expand_path('app', RAILS_ROOT)}' && grep -n --exclude=*.svn* -r '#{key}' *`
    unless output =~ /^$/
      puts "  !! " + warning + " !!" 
      puts '  ' + '.' * (warning.length + 6)
      puts output
    else
      puts "  Clean! Cheers for you!" 
    end
    puts
  end
end

Use rake to execute the task.

rake deprecated

With any luck you won’t get many warnings; it should give you a rough estimate on how long your upgrade may take.

Getting Rails 2

First you need to get the RC2 (or newer) tagged Rails source using rake. This downloads the Rails framework to your appliction’s vender/rails directory.

rake rails:freeze:edge TAG=rel_2-0-0_RC2
Upgrade issues

After upgrading, it’s worth running your test suite looking for any problems. The following are issues I ran into to get trawlr.com working.

Singular resources now map to plural controllers – Override by using the :controller option in routes.rb config/routes.rb
# Singleton reader resource
map.resource :reader, :controller => 'reader'
with_scope is now protected – Use .send(:with_scope) to call method

This caused an issue due to using the magic join model pattern, although the fix is relatively simple.

MyModel.send(:with_scope, args)
asset_packager plugin broken – Apply fix

The fabulous asset_packager plugin required a quick change to get working again (single-line change).

Index: vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
===================================================================
--- vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb    (revision 86)
+++ vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb    (working copy)
@@ -37,7 +37,7 @@
     private
       # rewrite compute_public_path to allow us to not include the query string timestamp
       # used by ActionView::Helpers::AssetTagHelper
-      def compute_public_path(source, dir, ext, add_asset_id=true)
+      def compute_public_path(source, dir, ext = nil, add_asset_id=true)
         source = source.dup
         source << ".#{ext}" if File.extname(source).blank?
         unless source =~ %r{^[-a-z]+://}

I still prefer this to the new Rails 2 asset merging as it also minifies JS and CSS files (including stripping comments) and also allows you to specify multiple asset groups (for example one grouping for the main site, another for an iPhone version). A word of caution if you use asset_packager you cannot take advantage of the new Rails 2 asset servers (see below).

# DOES NOT work with asset_packager
config.action_controller.asset_host = "http://asset%d.site.com" 
Nested route helpers changed – Must specifiy parent resource

If you have any nested routes it’s likely you will have to alter the named route helpers, for example child_path is now parent_child_path.

start_form_tag and end_form_tag have been deprecated – Quick fix is to replace with form_tag and </form> respectively.
<%= form_tag articles_path %> 
  <%= text_field :article, :title %> 
  <%= submit_tag "Save" %> 
</form>
render_without_layout has been deprecated – Use :layout => false instead.
render :layout => false
restful_authentication plugin is broken – Replace redirect_to_url (deprecated) in lib/authenticated_system.rb with to redirect_to.
Index: authenticated_system.rb
===================================================================
--- authenticated_system.rb    (revision 86)
+++ authenticated_system.rb    (working copy)
@@ -94,7 +94,7 @@
     # Redirect to the URI stored by the most recent store_location call or
     # to the passed default.
     def redirect_back_or_default(default)
-      session[:return_to] ? redirect_to_url(session[:return_to]) : redirect_to(default)
+      session[:return_to] ? redirect_to(session[:return_to]) : redirect_to(default)
       session[:return_to] = nil
     end
Optionally, rename your views

Rails 2 includes some changes to the way views are named. Previously you may have had show.rhtml and show.rjs which now become show.html.erb and show.js.rjs to indicate the mime type and template engines used. You don’t have to change your old views, but the following rake task should make it a quick change if you decide to. For trawlr.com I chose to use the new format for any new view templates but left the existing ones as they were (I’ll probably rename as changes are made on an individual basis).

lib/tasks/rails.rake
namespace 'views' do
  desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder, and .haml to .html.haml'
  task 'rename' do
    Dir.glob('app/views/**/[^_]*.rhtml').each do |file|
      puts `svn mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}`
    end

    Dir.glob('app/views/**/[^_]*.rxml').each do |file|
      puts `svn mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}`
    end

    Dir.glob('app/views/**/[^_]*.rjs').each do |file|
      puts `svn mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}`
    end
    Dir.glob('app/views/**/[^_]*.haml').each do |file|
      puts `svn mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}`
    end
  end
end
Resources

For more information on Rails 2 refer to the preview release blog post. For $9 you can pick up a copy of Ryan Daigle’s worthwhile Rails 2 PDF book available via peepcode.

Saturday October 20th, 2007

1.3

Mac OS X Leopard

From Slash Dot Dash, 11 months ago, 0 comments Comment

Mac OS X Leopard arrives October 26.

Before you rush to pre-order / buy it from Apple, for £85, visit Amazon where you can save yourself a fiver and pick up a copy for £79.98 with free delivery.

« older items