Hello, I'm a complete newbie in Ruby on Rails (.NET person, but have to support Ruby apps for a while).I've been given a task to display dynamically resized images from the file system on the web page.
After some reading I decided to use dragonfly.
Due to the current setup, version 0.6 works, the upper ones - blow the server ( not sure from which version it starts crashing)
And Ruby version is 1.8.6-p287 and I cannot change it.
By reading some articles that what I did
Added to the environment.rb
config.gem 'rmagick', :lib => 'RMagick'
config.gem 'rack-cache', :lib => 'rack/cache'
Created a class Album in models
class Album < ActiveRecord::Base
image_accessor :cover_image
end
int the home_controller,rb:
class HomeController < ApplicationController
def index
@album = Album.new
@album.cover_image = File.new('public/images/test.jpg')
end
end
In the index.html.eb:
<h1>Home</h1>
<br/>
<%= image_tag @album.cover_image.url('400x200') %>
However when I try to display the page. I'm getting
NoMethodError in HomeController#index
undefined method `cover_image_uid=' for #<Album >
Thinking it has something to do with Migrations,
I added a class in db folder:
class Album < ActiveRecord::Migration
def self.up
add_column :albums, :cover_image_uid, :string
end
def self.down
remove_column :albums, :cover_image_uid
end
end
But the error is still the same.
What I did wrong? There is no physical database, all I need is to read images from the file system
Any help will be appreciated.
Thanks.