Make sure the picture is copied with the new profile

This commit is contained in:
Petko Bordjukov 2015-08-19 23:55:22 +03:00
parent dd1786cba4
commit f14c3bc665
3 changed files with 14 additions and 1 deletions

View File

@ -45,6 +45,8 @@ gem 'jquery-datatables-rails'
gem 'morrisjs-rails' gem 'morrisjs-rails'
gem 'raphael-rails' gem 'raphael-rails'
gem 'copy_carrierwave_file'
group :development do group :development do
gem 'spring' gem 'spring'
gem 'spring-commands-rspec' gem 'spring-commands-rspec'

View File

@ -100,6 +100,8 @@ GEM
execjs execjs
coffee-script-source (1.9.1.1) coffee-script-source (1.9.1.1)
colorize (0.7.7) colorize (0.7.7)
copy_carrierwave_file (1.1.0)
carrierwave (~> 0.9)
countries (0.11.5) countries (0.11.5)
currencies (~> 0.4.2) currencies (~> 0.4.2)
i18n_data (~> 0.7.0) i18n_data (~> 0.7.0)
@ -356,6 +358,7 @@ DEPENDENCIES
capybara capybara
carrierwave carrierwave
coffee-rails coffee-rails
copy_carrierwave_file
devise devise
devise-i18n devise-i18n
factory_girl_rails factory_girl_rails
@ -390,3 +393,6 @@ DEPENDENCIES
therubyracer therubyracer
uglifier uglifier
yaml_db! yaml_db!
BUNDLED WITH
1.10.5

View File

@ -21,7 +21,12 @@ class User < ActiveRecord::Base
end end
def build_personal_profile(conference, params = {}) 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.conference = conference
new_personal_profile.assign_attributes params new_personal_profile.assign_attributes params
new_personal_profile new_personal_profile