diff --git a/app/controllers/phenotypes_controller.rb b/app/controllers/phenotypes_controller.rb index c2a4baf..f23b799 100644 --- a/app/controllers/phenotypes_controller.rb +++ b/app/controllers/phenotypes_controller.rb @@ -37,7 +37,7 @@ class PhenotypesController < ApplicationController @phenotype = Phenotype.find_by_characteristic(params[:phenotype][:characteristic]) end - unless @phenotype.known_phenotypes.include?(params[:user_phenotype][:variation]) + if @phenotype.known_phenotypes.include?(params[:user_phenotype][:variation]) == false @phenotype.known_phenotypes << params[:user_phenotype][:variation] end diff --git a/app/jobs/zipgenotypingfiles.rb b/app/jobs/zipgenotypingfiles.rb index ba70966..f8ec4ea 100644 --- a/app/jobs/zipgenotypingfiles.rb +++ b/app/jobs/zipgenotypingfiles.rb @@ -10,7 +10,7 @@ class Zipgenotypingfiles @user = User.find_by_id(up.user_id) print @user if @user.genotypes[0] != nil - @genotyping_files << @user.genotypes[0].fs_filename + @genotyping_files << @user.genotypes[0] end end @@ -19,7 +19,7 @@ class Zipgenotypingfiles if File.exists?(::Rails.root.to_s+"/public/data/zip/"+phenotype_id.to_s+"."+@time.to_s.gsub(" ","_")+".zip") == false Zip::ZipFile.open(::Rails.root.to_s+"/public/data/zip/"+phenotype_id.to_s+"."+@time.to_s.gsub(" ","_")+".zip", Zip::ZipFile::CREATE) do |zipfile| @genotyping_files.each do |gen_file| - zipfile.add(gen_file, "#{RAILS_ROOT}/public/data/"+ gen_file) + zipfile.add("user"+gen_file.user_id.to_s+"_file"+gen_file.id.to_s+"_yearofbirth"+gen_file.user.yearofbirth+"_sex"+gen_file.user.sex+"."+gen_file.filetype+".txt", "#{RAILS_ROOT}/public/data/"+ gen_file.fs_filename) end end end diff --git a/app/models/phenotype.rb b/app/models/phenotype.rb index 3cb48a5..b7c99d9 100644 --- a/app/models/phenotype.rb +++ b/app/models/phenotype.rb @@ -9,7 +9,10 @@ class Phenotype < ActiveRecord::Base text :characteristic end - def known_phenotypes - read_attribute(:known_phenotypes) || [] + after_create :default_array + + def default_array + self.known_phenotypes ||= [] end + end diff --git a/app/models/user.rb b/app/models/user.rb index 34c4d0b..a1459d2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ActiveRecord::Base has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>#", :head => "32x32#" }, :default_url => '/images/standard_:style.png' - attr_accessible :user_phenotypes_attributes, :variation, :characteristic, :name, :password_confirmation, :password, :email, :description, :homepages, :homepages_attributes,:avatar, :phenotype_creation_counter, :phenotype_additional_counter,:delete_avatar + attr_accessible :user_phenotypes_attributes, :variation, :characteristic, :name, :password_confirmation, :password, :email, :description, :homepages, :homepages_attributes,:avatar, :sex, :yearofbirth, :phenotype_creation_counter, :phenotype_additional_counter,:delete_avatar before_validation :clear_avatar validates_attachment_size :avatar, :less_than=>1.megabyte diff --git a/app/views/users/_edit.html.erb b/app/views/users/_edit.html.erb index 77d816b..1a777e2 100644 --- a/app/views/users/_edit.html.erb +++ b/app/views/users/_edit.html.erb @@ -42,6 +42,14 @@