RailsDAV now up for Rails 2.0.2

February 23rd, 2008

Hi all,

The RailsDAV plugin for integrating WebDAV controllers into your Rails application is now compatible with Rails 2.0.2. I’m doing a complete re-write to make RailsDAV easier to use and work with merb as well, but it’s slow going.

You can install RailsDAV with


ruby script/plugin install http://svn.liverail.net/svn/plugins/railsdav

RailsConf Europe - Wednesday Sessions - 3

September 19th, 2007

This is my last session of the day as i’ll have to run about by 5 and dive in a taxi to catch my flight.

Extending Rails to Use the Presenter Pattern

The Extending Rails to Use the Presenter Pattern could be re-titled talking Ruby On Rails beyond MVC by Jay Fields of ThoughtWorks.

He lost me quickly in ThoughtWorks-Speak, referencing everything in the ideas of Enterprise patterns. It’s Martin Fowler world. It’s tough to talk to people who may not be fully versed in your lingo and get the subtle references.

I’m gathering some ideas that Presenters are a way to make testing controllers easier and view testing isn’t really worth it (which I’ll agree with).

I’ll suggest checking out “Jay’s blog’:http://blog.jayfields.com/ if you are interested in these things as I didn’t get much out of this at all, Jay doesn’t even like the pattern. It was only about 25 minutes as well…. The person behind me just said “I’m feeling a bit swissed…..” and next to me “Possibly one of the most over-hyped talks here”

RailsConf Europe - Wednesday Sessions - 2

September 19th, 2007

First of all, some of the presentation downloads for RailsConf Europe have started appearing on the O’Reilly site here, so please run along and grab them. Nothing to see here.

Well ok, i’ll continue live-blogging from the afternoon sessions but I have a plane to catch soon :-)

Development Case Study: MindMeister

I’ve chosen the lest technical session because sometime the anecdote, the story, is more useful than the code. Development Case Study: MindMeister is the story off the online mind mapping tool “The google docs of mind mapping” apparently.

MindMeister It’s all AJAX (and a lot of it), tough call I think the interface could be way better in Flex and you have offline Mind-mapping possibilities with AIR.

They started with prototyping, then some design concepts , which all looked quite good if you ask me.

The name was the hardest thing to fine.

I hear that.. It is very hard to find a name. I agree you shouldn’t be obsessed with finding a free .com domain name, 37signals never did.

Private betas are good, 2 launches making it exclusive with lots of feedback. Starting with just friends but allowing invites to others. No longer than 2 months with an upgrade offer at the end.

They got lots of competitors and clones after launching which I think is a common problem, just make sure you are the brightest and the best. MindMeister have some good user stats, better traffic than their competitors (according to Alexa) but less features than the competitors. Usability is what makes them better. Every euro spent on design is worth it..

Recommendations

Marketing

Technical Issues

It seems MindMeister are going offline with Google Gears which is the right move, maybe AJAX was a good choice after all. Use a canvas library which turns to VRML on IE.. And Wirecard

I’ve got to day playing with it now MindMeister is pretty good, its slick works well and I can see how it would be both useful and easy with is important in brainstorming tools. Bravo guys!

Outsourcing to Open Source

Another non-technical session Outsourcing to Open Source from Tobias Luetke at “Shopify’:http://www.shopify.com/. I chose this because i’m a real fan of Shopify, JapedPixel and because it’s more relevant to my business than the others. But I wish I could also have gone to Exploring Very Rapid Web Development Techniques with Hobo by Tom Locke, but those the breaks..

Tobias is talking about Liquid which for those that don’t know is a safe templating method for Rails which you can give to customers to make their own designs/themes without them breaking your app. And he wrote it on the plain to RailsConf 2005!! Not only is it safe but only exposes what you want to expose ie.


class Product << ActiveRecord::Base
liquid_methods :title, :price, :description

If you don’t know about liquid, go look it up. If you ever developing a SaaS with needs safe themes for users, its a great fit. Tobias is also talking about Vision which is a downloadable theme engine which works offline. Using this tool the launched a competition for themes for shopify with an iPod nano, the people who entered then now do full time Shopify themeing and earn more money from it than JadedPixel!!

Vision works by donwloading a Mock version of Shopify with no backend but the objects returned have real like data. Like a massive test case your users can download and theme.

JapedPixel also issued the open source AcitveMerchant as a library for payment processing gateways. It is really useful contribution to Rails. It supports 40+ gateways. Often they are commission by shopify customers who pay a ruby developer to contribute a specific merchant to ActiveMerchant which then automatically appears in Shopify. This is a great example of crowd-sourcing helping the community which then helps your product. It’s like work for free….

Crowdsourcing

Crowdsourcing is a neologism for the act of taking a job traditionally performed by an employee or contractor, and outsourcing it to an undefined, generally large group of people, in the form of an open call. For example, the public may be invited to develop a new technology, carry out a design task, refine an algorithm or help analyze large amounts of data.

Examples of crowdsourcing are threadless.com, freebase, Mechanical Turk, PeertoPatent, OrganizedWisdom. Tobias simple example of CrowdSourcing is giving your users the ability to create a new translation of text in checkout and feed that back to the system. They get credit for the translation and shopify track the progress of translation. This allows them to email authors when they add a new string that needs translation.

A really good talk from Tobias but he could have gone into the theme of crowd-sourcing more than than shopifies use of it, then given the examples. Just a structural thing.

For those interested. Shopify use Solr and love it. From being a public facing Rails application they get some really random requests such as a whole Shakespeare text in a param!. The run 25,000 public facing with different URLs, so they get a lot of web-spiders on the servers. They use memcache generating a unique key for every possible input for a page, check memcache to see if it has a version. If memcache doesn’t have it they gzip it and stick it in memcache. They use version numbers of each object and the version number is part of the key, instead of expiring they just have to lookup a new key and get a cachemiss so generate it. No cache invalidation.

RailsConf Europe - Wednesday Sessions - 1

September 19th, 2007

Trying to make better choices today which shouldn’t be too hard. So I decided on following up my Flex on Rails background (which I havn’t be exploring recently), but since I was the first tutorial on integrating Flex and Rails, I thought i’d check on it’s progress.

Building Rich Internet Applications with Flex and Ruby on Rails

This session was given by Simeon Bateman, who although not Adobe is certainly a Flex expert and has real world in-anger experience of Flex and Rails.

Unfortunately Simeon spent far too much time on Flash background and had some problems with the Internet before getting to the good stuff. But did manage to quick demonstrations of

To his credit the last 15 mins was some of the best and explained the advantages of AMF over HTTPService with great examples. Simeon reckons that RubyAMF is the way to go in the future as WebORB has not been updated in a year, other people I know concur with that.

The other question for people interested in Flash/Flex is:

What is Thermo?

Creating Hybrid Web and Desktop Applications with Rails and Slingshot

A session by Joyent on Slingshot. This is something i’ve had an interest in for a while, in the realms of the online/offline applications. In theory Slingshot offers downloadable Rails applications that run on the desktop but syncs with an online web-application.

It will do syncronisations, and you can extend the sync-hooks and will need to implement aggregate_data for your models to get the sync works. But it won’t do conflict resolutions, but it does handle auto-increment ids and foreign-key problems on the syncronisation side which is a pretty tough problem. It can also sync files as well as data between online and offline. You must have timestamps on your model to sync models which make sense.

I will do some drag and drop stuff but only on Mac OS X. This is a real problem, and certainly AIR could overtake easily in this area. I would like to see how I could get RailsDAV working with Slingshot on this.

Your code will be visible in the download, it is after all Ruby. So it better be open-source application on a behind firewall deployment. I don’t think this is this biggest problem as people won’t be able to copy it without the web-application component.

They downloads can be big. 20MB is the initial hit and applications can be as big as 100MB.

Overall it seems better on Mac OSX than Windows. It has DMG packaging, XCode customisation and changing Info.plist while the Windows deployment looks a lot harder.

In practice, its not complete. Here is a list of things it won’t do (Yet)

But this is still one of the most interesting and innovative things being talked about at RailsConf Europe so was certainly worth intending. The presentation was well done and paced well, including presentation then questions then demo which is a lot to fill 45 minutes. Showing you don’t have to aim your presentation at the lowest common demoninator.

I’m wondering if you could just use the sync_controller parts of slingshot and write an AIR end…. Evil but useful.

Great demo..

RailsConf Europe - Wednesday Keynotes

September 19th, 2007

Partly due to having to check out my hotel, partly due to my hangover and partly due to not being bothered I missed today’s pre-roller advert by ThoughtWorks to today’s keynotes.

But i’m here now for the session on Best Practices. A bit late. Siting at the back nursing my headache.

The Best Practices session is very codey but still entertaining so far covering test-first, associations, method naming and chaining. Expressive Interfaces they call them, readability and undestanding. Now moving on to with_scope and the dangers of using a before_filter with a scoped command, hence reducing all queries to a limited scope. For instance only finding posts for the current user. Instead use associations:


current_user.posts.find(params[id])

But it has uses. You can use method_messaging with a with_scope and create a dynamic has_many association through a proxy. Similarly very cool but I can see that being mis-used also. I think using method_missing should be a last resort, documented heavily and only used if it significantly improves readability or time. Not really as a best practice.

The use of conditions and commands in Ruby can be confusing as there is many ways of doing it. The question, which can be understood quickest?


command if conditional?
....
if conditional?
  command
end
...
conditional? and command
...
conditional? && command
...

All of the above do the same. For me number 2 is clearest but involves more typing, but I hate mixing up commands with conditionals in an expression, and the speakers agree.

RailsConf Europe - Choosing sessions is so hard...

September 18th, 2007

Tuesday at RailsConf and choosing sessions is damn hard. Am I missing out on something really great going on in other room? Could the other guys be as boring as this speaker? With nothing more than a title and a synopsis we select from our buffet.

My bad decisions so far:

Making Rails More (Artificially) Intelligent

The speakers were in Spanish and their English was difficult to understand especially in a presentation context, but well done for giving it a go guys. Basically the talk introduced Bayesian graphs and probability tables, Bayesian classifiers and genetic algorithms and some Ruby libraries for using them. Unfortunately they didn’t make the Rails context at all. I think a talk on using these kind of algorithmic tools would be a winner with the right presentation context. But hard when it’s not your first language.

I learnt something and it’s worth checking the libraries if you ever feel you’ll need to solve an AI problem.

Meta-Magic in Rails: Become a Master Magician

Very entertaining and very popular, if the conference room had rafters people would be hanging from them. The room was packed. I would hate to go up against Dr Nic, the other rooms must have been empty.

I quit coding because I thought I hated it, turned out I just hated Java.

Dr Nic not only talked about fun little things with method_missing, const_missing and using the meta abilities of Ruby he used them as a weapon against other languages

Java is like… Keith Richards. not so cute anymore, can tell you stories about himself, can’t change his behavior

Great talk but Dr Nic was keen to point out that that in some cases the meta-magic is.

not useful but it is funny..

Really Scaling Rails

Was by a Twitter guy on scaling and had some bits of useful information but really didn’t engage. The really useful elements were a few tips such as how to encode the page peformance into every the response of every page. A shame.

Tabnav: Do We Really Need a Plugin for Tabbed Navigation?

A lovely talk by Italian speaker Paolo Dona who was engaging and funny. I expected the room to be near empty, after all who needs to hear about tabbed navigation. Instead Paolo packed the small room he was given, obviously they knew more than me.

Paolo’s main thing was that sure Ruby on Rails has meant he has had to write less code but he still spends the same amount of time writing HTML/CSS. In fact relatively he was spending much more time on HTML/CSS than coding.

where is DHH? I want to kill him. He has turned me into a designer.

So Paolo has widgets

  
ruby script/plugin install svn://svn.seesaw.it/widgets/trunk

Widgets for tabs, navigation, showhide, tablizer, tooltips, nubbins. To create user interface design patterns with less effort. It’s a fine idea and i’ll look to use them soon.

Not a bad spread for the food either…..

RailsConf Europe - In Berlin

September 18th, 2007

I arrived in Berlin yesterday and the sun was shining, that makes a change from London but today its raining, so exactly like London.

There is a large assembly of Railers, official figures have 39% Germans, 19% Brits, 11% Americans and the rest. Dave Thomas did his keynote last night (more to come) and DHH is just finishing his this morning.

I have some starter pictures for you:

LiveRail off to Berlin RailsConf Europe

September 13th, 2007

Just to confirm that I will be off to Berlin next week and will be hanging around at RailsConf Europe on the 18-19th. If you want to talk RailsDAV, Flex with Rails, Facebook or the state of the media industry in London, ask around for me.

I’ll be blogging from the event also, like many many others ;-)

Great Plugin for Facebook Apps

July 27th, 2007

If you’ve been working through the Facebook/Rails tutorials you might find this plugin useful.

Facebook on Rails is a sexy plugin for developing Facebook apps

It adds some useful functions to Rails for creating a Facebook application.

acts_as_fb_user


class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.column :uid, :integer, :null => false
      t.column :session_key, :string
    end

    add_index :users, :uid, :unique
  end

  def self.down
    drop_table :users
  end
end

class User < ActiveRecord::Base
  acts_as_fb_user

  def self.import(fbsession)
    user = self.find_or_initialize_by_uid(fbsession.session_user_id)

    # Assumes session_key never expires
    if fbsession.session_key != user.session_key
      user.session_key = fbsession.session_key
      user.save!
    end

    return user
  end
end


you can now do things with the user object such as get a user’s friends


>> u = User.find(1)
=> #<User:...>
>> u.friends
=> [1, 2, 3]

FBMLController

You can create FBMLControllers such as


class ApplicationController < Facebook::FBMLController
  before_filter :require_facebook_install
  before_filter :import_user

  private
  def import_user
    @user = User.import(fbsession)
  end
end

Although I still feel this doesnt need to be inherited and such just extend the ApplicationController.

API Calls.

Are now easier, no need to parse the Hpricot XML. And also you can use the fbsession in the Model objects (where it belongs)


class MyController < Facebook::FBMLController
  def friends
    @me         = Facebook::Users.get_info(fbsession.session_user_id, ['first_name', 'last_name'])
    @first_name = @me.first_name
    @last_name  = @me.last_name
    @friends    = Facebook::Friends.get
  end
end

Notifications like ActionMailer


class StampNotificationPublisher < Facebook::NotificationPublisher
  def stamp(friends)
    @to_ids = friends.map(&:uid)
    @text   = "just stamped on you" 
  end
end

I advise you check it out if you plan to write any applications for Facebook.

Continuing Facebook Applications with Ruby On Rails

July 16th, 2007

This is the continuing tutorial from the last post Tutorial on developing a Facebook platform application with Ruby On Rails where we can take the social recipe application and add some more Facebook features including posting to the feed, profile boxes, profile actions, the Facebook Query Language and sending out invitations to a user’s friends to come join in the cooking fun (oh boy). So lets get down to it, I’m presuming you have been through the first tutorial and have a working Facebook application. Even if you havn’t got it deployed today’s examples will work with an IFRAME application also.

Read the rest of this entry

Tutorial on developing a Facebook platform application with Ruby On Rails

June 29th, 2007

If you havn’t heard of Facebook. Where you been, living in a cave! Well you also probably know that in June 2007 Facebook opened a development platform for integrating new applications into Facebook, also codenamed F8. By the 24th June there were a 1,000 new applications available for the Facebook networkers to play with. According to both the online and traditional news media, Facebook have changed the game.

Well ZDNet are reporting that 1,000 developers a day are joining Facebook platform. That as it may, they are not all creating applications right away. The documentation is patchy, spread-out, difficult to understand and incomplete. It is a wonder so many applications are built because there is pain to go through to get there.

But this article is a complete tutorial for building a simple Facebook application in Ruby On Rails and should allow you to hit the ground running. We are going to create a recipes sharing application for Facebook from scratch.

UPDATE: The second part can be found here

Read the rest of this entry

Using Attached Files in Mephisto

June 14th, 2007

The Mephisto blog engine has added the facility to attach files to an article rather than just embedding in the article content itself.

I’ve now added some code which will show an attached image at the start on an article. You can do this by editing the home.liquid template to something like this:


{% if article.assets.size != 0 %}
  {% for asset in article.assets %}
    {% if asset.is_image %}
      <p class="image"><img src="{{ asset.path }}"/></p>
    {% endif %}
  {% endfor %}
{% endif %}

Contribution Manager. A Rails charity application

June 13th, 2007

A UK internet consultant I know, Allen Brown, has just released his first Ruby On Rails Application. Contribution Manager allows UK charities to track contributions and assists in making claims.

I had a chat to Allen about releasing his first Rails application:

Tell me a little about contribution manager?

It’s intended to help small charities collect the money they are entitled to claim back from the government. Estimates of the amount that went unclaimed last year range between £700M and £800M and I suspect the usual reason is that is just looks too complex. Contribution Manager makes it quite straightforward, generating the claim form for you and keeping track of all the details necessary to keep the tax man happy.

What made you want to develop contribution manager?

My business partner (also happens to be my wife) was doing the Gift Aid admin for a large church in London and convinced me to replace her old single-user Access database with a shiny new Ajax-enabled SQL-powered website. I made it very flexible – as Rails encourages such practices – and I soon realised that the solution would work for any small charity.

Which hosting solution did you plug for?

I was relatively early to Rails and quickly threw in my lot with those nice people at Textdrive. They are now Joyent.

Did they do a good job?

They are Rails experts but the support isn’t always as responsive as I’d like. However, the site was very reliable and quick once I mastered Lighttpd.

Who built it for you? How was you/their experience of using it?

I built it myself. It was my first Rails project. Rails is a fantastic framework and there’s no doubt that you can easily save yourself a couple of days by doing something automagically with a few lines of code. The problem I find is that the documentation is still in its infancy and you can lose those two days again trying to track down something that isn’t happening automagically when you want it to – or is when you don’t.

How much money did contribution manager take to set up?

Joyent bills me $15 a month and the domain costs me $9 a year. Oh yes, and the image of a piggy bank cost $1 from Fotolia. The rest was just manpower. My manpower to be specific. I did pay out quite a lot for a bespoke web design that I later largely abandoned but I’ve learnt from that experience and would buy myself a $50 template next time and modify it as I needed.

So there you go, I think Allen’s story says you don’t need to be a rockstar rails programmer or need plenty of cash to release your application

Liverail to RailsMachine

June 13th, 2007

I’ve just completed a switch over of hosting on liverail.net from TextDrive to RailsMachine and I must say I could not be happier with the experience.

The TextDrive hosting I was using was a shared installation and mephisto is not happy on shared hosting. Instead the virtualised Linux hosting provided by Railsmachine is truly excellent. All my previous problems with Mephisto such as out of memory errors, asset problems, comment problems and submitting large posts has gone. It is also considerably faster.

The capistrano deployment recipes on RailsMachine made it supremely easy to deploy a Rails application.

Right result all round. I can now get round to actually blogging rather than fighting to keep it running.

I havn’t as yet migrated the svn repository so you may be unable to download the RailsDAV or mephisto webdav plugins.

UPDATE: Anonymous SVN access is back. For anyone interested to setup read access for anonymous SVN at railsmachine I followed the instructions at How do I install mod_dav_svn? but changed the line in the domain config /etc/httpd/conf/apps/.conf from

Require valid-user
to
  <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  </LimitExcept>

WebDAV plugin for Mephisto

May 5th, 2007

I’ve put together a WebDAV plugin for mephisto the rails blogging engine which runs this site which adds 2 webdav controllers using RailsDAV.

1. Theme DAV Controller – Allows a standard file mount of the mephisto themes directory protected by a BASIC authentication requiring you to log in as an admin user. This means you can edit the life themes from your favourite editor. All general file functions such as move, copy, delete and make folder should all be good.

2. Asset DAV Controller – Allows uploading and downloading of Mephisto assets through the file system mounting. This is a great example of using RailsDAV with attachment_fu which i’ll go into greater detail about in a later post. It’s worth noting that if you upload images, the resized versions thumb and tiny are also then available for download. You can’t create new directories but you can delete assets.

For now installing the mephisto_dav plugin has the following pre-reqs:

So installation is a matter of running the following in your mephisto rails directory:


ruby script/plugin install http://svn.liverail.net/svn/plugins/railsdav
ruby script/plugin install http://svn.liverail.net/svn/plugins/mephisto_dav

Then after starting your server you can connect your favourite WebDAV client (such as Finder on Mac OS X) to http://server/theme_dav or http://server/asset_dav

UPDATE: I realise that the comments havn’t been working on liverail and the railsdav lighthouse project was shut. Both should be working now.

4 comments »