diff --git a/Gemfile b/Gemfile index 2b6cf48..fb93bc3 100644 --- a/Gemfile +++ b/Gemfile @@ -45,6 +45,8 @@ gem 'jquery-datatables-rails' gem 'morrisjs-rails' gem 'raphael-rails' +gem 'copy_carrierwave_file' + group :development do gem 'spring' gem 'spring-commands-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 35fd691..3754a51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,6 +100,8 @@ GEM execjs coffee-script-source (1.9.1.1) colorize (0.7.7) + copy_carrierwave_file (1.1.0) + carrierwave (~> 0.9) countries (0.11.5) currencies (~> 0.4.2) i18n_data (~> 0.7.0) @@ -356,6 +358,7 @@ DEPENDENCIES capybara carrierwave coffee-rails + copy_carrierwave_file devise devise-i18n factory_girl_rails @@ -390,3 +393,6 @@ DEPENDENCIES therubyracer uglifier yaml_db! + +BUNDLED WITH + 1.10.5 diff --git a/app/models/user.rb b/app/models/user.rb index a9cddd1..3b6fdca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,7 +21,12 @@ class User < ActiveRecord::Base end def build_personal_profile(conference, params = {}) - new_personal_profile = personal_profiles.last.try(:dup) || personal_profiles.build + if personal_profiles.last.present? + new_personal_profile = personal_profiles.last.try(:dup) + CopyCarrierwaveFile::CopyFileService.new(personal_profiles.last, new_personal_profile, :picture).set_file + else + new_personal_profile = personal_profiles.build + end new_personal_profile.conference = conference new_personal_profile.assign_attributes params new_personal_profile