Re: [dragonfly-users] newbie question on dragonfly

66 views
Skip to first unread message

Mark Evans

unread,
Oct 1, 2012, 5:56:53 AM10/1/12
to dragonf...@googlegroups.com
Hi
you need to do "rake db:migrate" to add the cover_image_uid= method
however… you said you don't have a physical database?
in that case, you don't need to use models.
You can use fetch_file instead (see http://markevans.github.com/dragonfly/file.GeneralUsage.html)… though this isn't available in 0.6 so you should try to upgrade if you can


On 26 Sep 2012, at 18:22, olegy wrote:

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'
config.gem 'dragonfly',  :lib => 'dragonfly/rails/images', :source => 'http://gemcutter.org'


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.


Reply all
Reply to author
Forward
0 new messages