Making a demo login with restful_authentication

In order for someone to give The Project (Min Packning) a try it was required to register an account and provide a valid e-mail address. This is an obstacle, so I wanted to add a way for people to try the service without registering. It was actually very easy. I created a demo user account, added a demo method to SessionsController and added suitable routing. Now visiting www.minpackning.se/demo will give a logged in session as the demo user.

In app/controllers/sessions_controller.rb:

  def demo
    params[:login] = 'demologin'
    params[:password] = 'demopassword'
    create
  end

In config/routes.rb:

  map.demo '/demo', :controller => 'sessions', :action => 'demo'

My first AJAX!

Probably years after everyone else, I’ve made my first AJAX-enabled web page today. As I do this from within Ruby on Rails, it was virtually painless to remove or replace a piece of HTML.

My next AJAX step was to get in_place_editing working. The first problem was the InvalidAuthenticityToken and the second issue was that I use a different controller, but now it works fine!

Printing “Things” in The Project

The Project will allow users to create and edit something I call “Things” in this article. One feature that is quite high on the priority list is to be able to print Things. I found the article “Print this page” with Ruby on Rails but I wanted a separate page for printing a Thing. I have created a layout called “print” and my ThingsController contains a method like this:

  def print
    @thing = current_user.things.find(params[:id])
    render :layout => "print"
  end

My routes.rb contains something like:

  map.print_thing '/things/:id/print',
    :controller => 'things', :action => 'print'

The print layout is currently bare-bone HTML with this script snippet right before </body>:

<script type="text/javascript">javascript:print()</script>

The humble beginnings of The Project

Yesterday and today I took some time to work on The Project. (Tomorrow I’m back at work, so much for a holiday project.) I tossed aside requirements on a strictly Swedish interface, so the controller names are in English and I don’t use Ola Bini‘s Swedish Rails yet. Honestly I haven’t done any TDD/BDD yet either. The excuse I tell myself that I only cannot learn everything at the same time.

I lookup things in the Rails 1.2 book but as I’m using Rails 2 I’m browsing the web quite a bit too. One very useful resource I’ve found so far is Akita’s tutorial. So far I have restful_authentication working (from the restful_authentication gem), a “welcome” controller and two domain-specific models. I’m working on two related controllers.

A few words about using an activation step when registering a new user. I started out with the Restful_authentication & Activation instructions but I thought that having a HOST global variable was really silly so I found the retardase_inhibitor plugin and now I can properly generate URLs in the ActionMailer.

Holiday project!

The day before yesterday I registered a domain name for a new project and yesterday (while recovering from a really upset stomach) I wrote three A5 pages with a database model, sketchy requirements and possible features. All from very basic ones (“It shall be possible to register a new user account”) to some that are way into the future (“A user can customize font and color”). Maybe five of those requirements will make the cut for a first version of the site…

I’ve promised myself to write the project in Ruby on Rails (not a PHP hack like folkmun.se) and do my best to use TDD or maybe even BDD. If I go for BDD there’s an RSpec plugin for Ruby on Rails and I’ve found some interesting reading, for example Developing a Rails model using BDD and RSpec, Part 1.

So, will it fly? Evan Williams lists a number of questions for evaluation of product ideas:

  • Tractability: How difficult will it be to launch a worthwhile version 1.0?
  • Obviousness: Is it clear why people should use it?
  • Deepness: How much value can you ultimately deliver?
  • Wideness: How many people may ultimately use it?
  • Discoverability: How will people learn about your product?
  • Monetizability: How hard will it be to extract the money?
  • Personally Compelling: Do you really want it to exist in the world?