First I installed rails 3.2
gem install rails -v=3.2.0
Then I generated a new Rails app
rails new subcryption
Then I copied the whole of the app folder from my old app to the new one
Then I copied the config/database.yml from the old app to config/ in the new one
Then I altered the contents of the front page, index.html.erb, like this:
It was
 
  <%= image_tag( url_for( :controller => 'main', :action => 'image', 
                       :id => '1' ), :size => "500x375" ) %>
 
  
and now it's
  
  <%= image_tag(
    url_for({:controller => 'main', :action => 'image', 
                :what => 'image', :id => '1'}),
            :size => "500x375", :class => 'quick', 
                :remote => true ) %>
 
  
Then I edited Gemfile, so it looks like this:
 source 'http://rubygems.org'
 gem 'rails', '>=3.2.0'
 gem 'therubyracer'
 
 gem 'rmagick'
 gem 'gruff'
 gem 'mysql' 
 gem 'sass', '~> 3.1.3'
 gem 'coffee-script'
 group :test do
   gem 'turn', :require => false
 end
Then
gem install bundler
bundle install --path=vendor/bundle
That updates your gems with the gems in the Gemfile and their dependencies
I always find routes.rb difficult. What I do, is make it as simple as possible, and
have the controller actions sort out what to do from the parameters that get passed from
the erb pages, through routes, to the controllers. Anyway it now looks like this:
Subcryption::Application.routes.draw do
  root :to => 'main#index'
  match 'main/show' => 'main#show'
  match 'assets' => 'main#image'
end
and the controller sorts out the image drawing stuff. It used to have 
two methods, image and weather (for the two pictures on the front 
page of subcryption.com), but now it only has one, image, and it uses the 
parameter 'what' (see index.html.erb above) to decide which image it is rendering:
  def image
    @blob = Graph.new 
    send_data (params[ :what ] == 'image' ? @blob.image : @blob.scene),
     :disposition => 'inline',
     :type => 'image/png',
     :filename => @blob.file_name
  end
Graph is a model, based on imagemagick and gruff. Some of it looks like this:
    dada = [1,2,3,1,5,2,1,0,0,7,8,4,3,0,1,1,3,2,2,8,7,7,5,0,4,9]
    g = Gruff::Line.new(dada) 
    g.x_axis_label = 'Years'
    g.y_axis_label = 'Degrees'
    g.marker_font_size = 16
    g.data('temp', dada)
    return g.to_blob
I copied the whole of public/images into app/assets/images, public/stylesheets into 
app/assets/stylesheets, and public/javascripts into app/assets/javascripts. 
Some of them don't need to be in both places, but some of them do.
This is all to do with the 'asset pipeline'. Why the asset pipeline can't look 
in public/images etc. I don't know.
To run it, it's 'rails server' instead of 'script/server'.
 |