Rake aborted! Validation failed:

Trying to populate a database with some users using rake db:populate.

But im getting this error trace:

** Invoke db:populate (first_time)
** Invoke db:populate:accounts (first_time)
** Invoke db:populate:setup (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:populate:setup
** Execute db:populate:accounts
[populate] accounts
rake aborted!
Validation failed: Logo failed to be processed.
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1090:in
`save_without_dirty!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:87:in
`save_without_transactions!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in
`save!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in
`transaction'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in
`transaction'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in
`save!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:208:in
`rollback_active_record_state!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in
`save!'
/usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist/active_record.rb:55:in
`make'
/home/andersnguyen/rubyprojects/mediapilot/lib/tasks/populate.rake:35
/usr/lib/ruby/1.8/rake.rb:636:in `call'
/usr/lib/ruby/1.8/rake.rb:636:in `execute'
/usr/lib/ruby/1.8/rake.rb:631:in `each'
/usr/lib/ruby/1.8/rake.rb:631:in `execute'
/usr/lib/ruby/1.8/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:607:in `invoke_prerequisites'
/usr/lib/ruby/1.8/rake.rb:604:in `each'
/usr/lib/ruby/1.8/rake.rb:604:in `invoke_prerequisites'
/usr/lib/ruby/1.8/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:583:in `invoke'
/usr/lib/ruby/1.8/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2029:in `each'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:2023:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2001:in `run'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:28

here is the populate.db file:

# encoding: utf-8

class Range
  def random
    rand(last - first + 1) + first
  end
end

namespace :db do

  desc "Erase and fill database"
  task :populate => [
    'db:populate:accounts',
    'db:populate:users',
    'db:populate:memberships',
    'db:populate:feeds',
    'db:populate:events',
    'db:populate:sources',
    'db:populate:editorials',
    'db:populate:social_posts',
    'db:populate:variables',
    'db:populate:statistics',
    'feed:retrieve'
  ]

  namespace :populate do

    task :setup => :environment do
      require File.join(Rails.root, 'spec', 'blueprints')
    end

    task :accounts => 'db:populate:setup' do
      puts "[populate] accounts"
      Account.delete_all
      Account.make(:name => 'SJ', :logo =>
File.open(Rails.root.join('features/fixtures/logo-sj.png')))
      Account.make(:name => 'Telia', :logo =>
File.open(Rails.root.join('features/fixtures/logo-telia.png')))
      Account.make(:name => 'Stena Line', :logo =>
File.open(Rails.root.join('features/fixtures/logo-stena.png')))
      Account.make(:name => 'Max', :logo =>
File.open(Rails.root.join('features/fixtures/logo-max.png')))
      Account.make(:name => 'Coop', :logo =>
File.open(Rails.root.join('features/fixtures/logo-coop.png')))
    end

    task :users => 'db:populate:setup' do
      puts "[populate] users"
      User.delete_all
      User.make(:password => 'test1234', :email => "admin@elabs.se",
:role => 'admin', :locale => "en")
      User.make(:password => 'test1234', :email => "analyst@elabs.se",
:role => 'analyst', :locale => "en")
      User.make(:password => 'test1234', :email => "customer@elabs.se",
:role => 'customer', :locale => "en")
      User.make(:password => 'test1234', :email => "swedish@elabs.se",
:role => 'admin', :locale => "sv")
      12.times { User.make(:role => (User::ROLES - ['Admin']).rand) }
    end

    task :memberships => 'db:populate:setup' do
      puts "[populate] memberships"
      Membership.delete_all
     User.find(:all, :conditions => "role != 'Admin'").each do | user |
        if user.customer?
          user.accounts << Account.random
        else
          (1..4).random.times { user.accounts << Account.random }
        end
      end
    end

    task :sources => 'db:populate:setup' do
      puts "[populate] sources"
      Source.delete_all
      Source.make(:name => 'Aftonbladet', :circulation => 1_232_432,
:category => 'popular')
      Source.make(:name => 'DN', :circulation => 1_632_653, :category =>
'large_city')
      Source.make(:name => 'Expressen', :circulation => 823_583,
:category => 'popular')
      Source.make(:name => 'Göteborgs-Posten', :circulation => 442_556,
:category => 'large_city')
      Source.make(:name => 'Sydsvenska Dagbladet', :circulation =>
350_834, :category => 'local')
      Source.make(:name => 'Dagens Industri', :circulation => 2_342_342,
:category => 'trade')
      Source.make(:name => 'Engadget', :circulation => 7_234_618,
:category => 'trade')
      Source.make(:name => 'Tech Crunch', :circulation => 13_546_245,
:category => 'trade')
      Source.make(:name => 'Wired', :circulation => 1_350_000, :category
=> 'trade')
    end

    task :feeds => 'db:populate:setup' do
      puts "[populate] feeds"
      Feed.delete_all

     Account.all.each do | account |
        [
          ['http://www.dn.se/m/rss/toppnyheter', "DN.se toppnyheter"],
          ['http://www.gp.se/1.16943', 'Göteborgsposten'],
          ['http://www.aftonbladet.se/sportbladet/rss.xml', 'Aftonbladet
sportnyheter'],
          ['http://www.sr.se/rssfeed/rssfeed.aspx?rssfeed=83&format=1',
'Sveriges Radio EKOT']
       ].each do | url, name |
           account.feeds.make(:name => name, :url => url, :category =>
'editorial')
        end
        [
          ['http://twitter.com/statuses/user_timeline/17023971.rss',
"eLabs on Twitter", false],
          ['http://twitter.com/statuses/user_timeline/23775395.rss',
'MediaPilot on Twitter', false],
          ['http://friendfeed.com/cjkihlbom?format=atom', 'CJ Kihlbom on
FriendFeed', true],
          ['http://feeds.digg.com/digg/upcoming.rss', 'Fresh stuff on
Digg', true]
       ].each do | url, name, preview |
           account.feeds.make(:name => name, :url => url, :category =>
'social', :preview => preview)
        end
      end
    end

    task :events => 'db:populate:setup' do
      puts "[populate] events"
      Event.delete_all
     Account.all.each do | account |
        (10..15).random.times { Event.make(:account => account) }
      end
    end

    task :editorials => 'db:populate:setup' do
      puts "[populate] editorials"
      Editorial.delete_all
      Account.all.each do | account |
        (60..100).random.times { Editorial.make(:printed, :account =>
account, :event => account.events.random, :source => Source.random) }
        account.editorial_feed_items.each do | item |
          Editorial.make(:web, :account => account, :feed_item => item,
:url => item.url, :headline => item.title, :event =>
account.events.random, :source => Source.random) if(rand(2).zero?)
        end
      end
    end

    task :social_posts => 'db:populate:setup' do
      puts "[populate] social_posts"
      SocialPost.delete_all
     Account.all.each do | account |
     account.social_feed_items.each do | item |
          SocialPost.make(:account => account, :feed_item => item,
:headline => item.title) if(rand(2).zero?)
        end
      end
    end

    task :variables => 'db:populate:setup' do
      puts "[populate] custom variables"
      Variable.delete_all
      VariableOption.delete_all
      EditorialVariableOption.delete_all
      SocialPostVariableOption.delete_all
     Account.all.each do | account |
        products = account.variables.make(:name => 'Products',
:multiple_choice => true, :category => 'editorial')
       %w(Fanta Sprite Cola).each do | option_name |
          products.options.make(:name => option_name)
        end
        flavors = account.variables.make(:name => 'Flavors',
:multiple_choice => false, :category => 'editorial')
       %w(Sweet Sour Bitter Salty).each do | option_name |
          flavors.options.make(:name => option_name)
        end
        sugar_content = account.variables.make(:name => 'Sugar Content',
:multiple_choice => false, :category => 'social')
       %w(Diabetes High Medium Low).each do | option_name |
          sugar_content.options.make(:name => option_name)
        end

        product_options = products.options
        flavor_options = flavors.options
       account.editorials.each do | editorial |
          editorial.variable_options.push(*product_options.shuffle[0,rand(4)])
          editorial.variable_options.push(flavor_options.rand)
        end

        sugar_content_options = sugar_content.options
       account.social_posts.each do | social_post |
          social_post.variable_options.push(sugar_content_options.rand)
        end

      end

    end

    task :statistics => 'db:populate:setup' do
      puts '[populate] statistics'
      Statistic.delete_all
     Account.all.each do | account |
        account.statistics.make(:pie, :category => 'editorial', :name =>
'Favorability Overview', :group_parameter_one_type => 'favorability')
        account.statistics.make(:bar, :category => 'editorial', :name =>
'Media types', :group_parameter_one_type => 'medium',
:group_parameter_two_type => nil)
        sugar_content = account.variables.find_by_name('Sugar Content')
        account.statistics.make(:bar, :category => 'social', :name =>
'Sugar content per favorability', :group_parameter_one_type =>
"variable_#{sugar_content.id}", :group_parameter_two_type =>
'favorability')
        account.statistics.make(:line, :category => 'social', :name =>
'Development of Comments', :group_parameter_one_type => 'time_months',
:group_parameter_two_type => 'comments')
      end
    end
  end

end

···

--
Posted via http://www.ruby-forum.com/.

This is Ruby-Talk, mainly covering Ruby specific topics, not Rails
development questions.

You will get better results asking this in a Rails-specific forum,
check their site for info:

A hint for you to investigate: If is failing to process your
attachment (Logo) must be there is no attachment processor installed
(ImageMagick?).

···

On Oct 12, 5:42 am, Anders Nguyen <nguyen.and...@gmail.com> wrote:

Trying to populate a database with some users using rake db:populate.

--
Luis Lavena

Ive installed ImageMagick already :S

andersnguyen@andersnguyen-laptop:~/rubyprojects/mediapilot$ display
-version
Version: ImageMagick 6.6.0-10 2010-10-07 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

This is a list of the gems I've installed and rmagick is in it:

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
annotate (2.4.0)
be_valid_asset (1.1.1)
builder (2.1.2)
capybara (0.3.9)
carrierwave (0.4.5)
celerity (0.7.9)
childprocess (0.0.7)
columnize (0.3.1)
contextually (0.1)
crack (0.1.8)
cucumber (0.9.2, 0.8.5)
cucumber-rails (0.3.2)
culerity (0.2.12)
database_cleaner (0.5.2)
devise (0.7.5)
diff-lcs (1.1.2)
email_spec (0.3.7)
faker (0.3.1)
fakeweb (1.3.0)
feed_me (0.7.0)
ffi (0.6.3)
formtastic (0.9.8)
gherkin (2.2.8, 2.1.5)
gruff (0.3.6)
has_scope (0.5.0)
i18n (0.3.7)
inherited_resources (1.0.6)
jruby (0.0.1)
json (1.4.6)
json_pure (1.4.6)
linecache (0.43)
machinist (1.0.6)
mime-types (1.16)
mocha (0.9.8)
mysql (2.8.1)
nokogiri (1.4.1)
polyglot (0.3.1)
prawn (0.8.4)
prawn-core (0.8.4)
prawn-fast-png (0.2.1)
prawn-layout (0.8.4)
prawn-security (0.8.4)
rack (1.0.1)
rack-test (0.5.4)
rails (2.3.5)
rails_sequel (0.2.1)
rake (0.8.7)
ramhoj-scruffy (0.2.8)
random_data (1.5.1)
remarkable (3.1.13)
remarkable_activerecord (3.1.13)
remarkable_rails (3.1.13)
responders (0.4.7)
rmagick (2.13.1)
rspec (1.3.0)
rspec-rails (1.3.2)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
rubygems-update (1.3.7)
rubyzip (0.9.4)
savon (0.7.6)
selenium-webdriver (0.0.29)
sequel (3.10.0)
state_machine (0.8.1)
term-ansicolor (1.0.5)
treetop (1.4.8)
trollop (1.16.2)
validates_timeliness (2.3.1)
warden (0.6.5)
will_paginate (2.3.12)
yalab-ruby-ods (0.0.0)
ZenTest (4.4.0)

I will try to reinstall ImageMagic and see if there maybe a problem with
my installation.

Im currently working on ubuntu

···

--
Posted via http://www.ruby-forum.com/.

Luis Lavena wrote in post #949462:

···

On Oct 12, 5:42am, Anders Nguyen <nguyen.and...@gmail.com> wrote:

Trying to populate a database with some users using rake db:populate.

This is Ruby-Talk, mainly covering Ruby specific topics, not Rails
development questions.

You will get better results asking this in a Rails-specific forum,
check their site for info:

http://rubyonrails.org/community

A hint for you to investigate: If is failing to process your
attachment (Logo) must be there is no attachment processor installed
(ImageMagick?).

Can admin move this question to the rails thread.

I have ImageMagick installed. Can i have done something wrong with the
installation of Imagemagic?

Im currently working on Ubuntu

--
Posted via http://www.ruby-forum.com/.

Can admin move this question to the rails thread.

I doubt it, since the ruby forum is a gateway to the Usenet group /
mailing lists of the Ruby world.

I have ImageMagick installed. Can i have done something wrong with the
installation of Imagemagic?

You'd need the ImageMagick gem, I guess (no idea what it is called),
so that Rake can make use of ImageMagick from within Ruby.

···

On Tue, Oct 12, 2010 at 4:53 PM, Anders Nguyen <nguyen.anders@gmail.com> wrote:

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.

It's called RMagick. http://rubygems.org/gems/rmagick

···

On Tue, Oct 12, 2010 at 11:32 AM, Phillip Gawlowski < cmdjackryan@googlemail.com> wrote:

On Tue, Oct 12, 2010 at 4:53 PM, Anders Nguyen <nguyen.anders@gmail.com> > wrote:
> I have ImageMagick installed. Can i have done something wrong with the
> installation of Imagemagic?

You'd need the ImageMagick gem, I guess (no idea what it is called),
so that Rake can make use of ImageMagick from within Ruby.