rake aborted! Validation failed:

A

Anders Nguyen

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_recor=
d/validations.rb:1090:in
`save_without_dirty!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/dirty.rb:87:in
`save_without_transactions!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/transactions.rb:200:in
`save!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/connection_adapters/abstract/database_statements.rb:136:in
`transaction'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/transactions.rb:182:in
`transaction'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/transactions.rb:200:in
`save!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/transactions.rb:208:in
`rollback_active_record_state!'
/home/andersnguyen/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_recor=
d/transactions.rb:200:in
`save!'
/usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist/active_record.r=
b: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 =3D> [
'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 =3D> :environment do
require File.join(Rails.root, 'spec', 'blueprints')
end

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

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

task :memberships =3D> 'db:populate:setup' do
puts "[populate] memberships"
Membership.delete_all
User.find:)all, :conditions =3D> "role !=3D '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 =3D> 'db:populate:setup' do
puts "[populate] sources"
Source.delete_all
Source.make:)name =3D> 'Aftonbladet', :circulation =3D> 1_232_432,
:category =3D> 'popular')
Source.make:)name =3D> 'DN', :circulation =3D> 1_632_653, :category=
=3D>
'large_city')
Source.make:)name =3D> 'Expressen', :circulation =3D> 823_583,
:category =3D> 'popular')
Source.make:)name =3D> 'G=C3=B6teborgs-Posten', :circulation =3D> 4=
42_556,
:category =3D> 'large_city')
Source.make:)name =3D> 'Sydsvenska Dagbladet', :circulation =3D>
350_834, :category =3D> 'local')
Source.make:)name =3D> 'Dagens Industri', :circulation =3D> 2_342_3=
42,
:category =3D> 'trade')
Source.make:)name =3D> 'Engadget', :circulation =3D> 7_234_618,
:category =3D> 'trade')
Source.make:)name =3D> 'Tech Crunch', :circulation =3D> 13_546_245,=

:category =3D> 'trade')
Source.make:)name =3D> 'Wired', :circulation =3D> 1_350_000, :categ=
ory
=3D> 'trade')
end

task :feeds =3D> '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=C3=B6teborgsposten'],
['http://www.aftonbladet.se/sportbladet/rss.xml', 'Aftonbladet
sportnyheter'],
['http://www.sr.se/rssfeed/rssfeed.aspx?rssfeed=3D83&format=3D1=
',
'Sveriges Radio EKOT']
].each do | url, name |
account.feeds.make:)name =3D> name, :url =3D> url, :category =3D='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=3Datom', 'CJ Kihlbom o=
n
FriendFeed', true],
['http://feeds.digg.com/digg/upcoming.rss', 'Fresh stuff on
Digg', true]
].each do | url, name, preview |
account.feeds.make:)name =3D> name, :url =3D> url, :category =3D='social', :preview =3D> preview)
end
end
end

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

task :editorials =3D> 'db:populate:setup' do
puts "[populate] editorials"
Editorial.delete_all
Account.all.each do | account |
(60..100).random.times { Editorial.make:)printed, :account =3D>
account, :event =3D> account.events.random, :source =3D> Source.random) }=

account.editorial_feed_items.each do | item |
Editorial.make:)web, :account =3D> account, :feed_item =3D> ite=
m,
:url =3D> item.url, :headline =3D> item.title, :event =3D>
account.events.random, :source =3D> Source.random) if(rand(2).zero?)
end
end
end

task :social_posts =3D> '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 =3D> account, :feed_item =3D> item,
:headline =3D> item.title) if(rand(2).zero?)
end
end
end

task :variables =3D> '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 =3D account.variables.make:)name =3D> 'Products',
:multiple_choice =3D> true, :category =3D> 'editorial')
%w(Fanta Sprite Cola).each do | option_name |
products.options.make:)name =3D> option_name)
end
flavors =3D account.variables.make:)name =3D> 'Flavors',
:multiple_choice =3D> false, :category =3D> 'editorial')
%w(Sweet Sour Bitter Salty).each do | option_name |
flavors.options.make:)name =3D> option_name)
end
sugar_content =3D account.variables.make:)name =3D> 'Sugar Conten=
t',
:multiple_choice =3D> false, :category =3D> 'social')
%w(Diabetes High Medium Low).each do | option_name |
sugar_content.options.make:)name =3D> option_name)
end

product_options =3D products.options
flavor_options =3D 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 =3D sugar_content.options
account.social_posts.each do | social_post |
social_post.variable_options.push(sugar_content_options.rand)
end

end

end

task :statistics =3D> 'db:populate:setup' do
puts '[populate] statistics'
Statistic.delete_all
Account.all.each do | account |
account.statistics.make:)pie, :category =3D> 'editorial', :name =3D='Favorability Overview', :group_parameter_one_type =3D> 'favorability')
account.statistics.make:)bar, :category =3D> 'editorial', :name =3D='Media types', :group_parameter_one_type =3D> 'medium',
:group_parameter_two_type =3D> nil)
sugar_content =3D account.variables.find_by_name('Sugar Content')=

account.statistics.make:)bar, :category =3D> 'social', :name =3D>=

'Sugar content per favorability', :group_parameter_one_type =3D>
"variable_#{sugar_content.id}", :group_parameter_two_type =3D>
'favorability')
account.statistics.make:)line, :category =3D> 'social', :name =3D='Development of Comments', :group_parameter_one_type =3D> 'time_months',
:group_parameter_two_type =3D> 'comments')
end
end
end

end

-- =

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

Luis Lavena

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?).
 
P

Phillip Gawlowski

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.

--
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.
 
A

Anders Nguyen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top