- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
def update
error = false
if params[:geografic].present? && ((params[:geografic] & IsoCountryCodes.all.map{|c|c.alpha2.downcase}) == params[:geografic])
current_user.profile.geografic = params[:geografic]
else
error = true
flash[:alert] ||= ''
flash[:alert] << "Need select countries. "
end
begin
current_user.profile.sectors_of_interests = Sector.find(params[:sectors_of_interests])
rescue
error = true
flash[:alert] ||= ''
flash[:alert] << 'Can not find sectors. '
end
if params[:profession_id].present? && profession = Profession.find(params[:profession_id])
current_user.profile.update_attribute(:profession_id, params[:profession_id])
else
error = true
flash[:alert] ||= ''
flash[:alert] << 'Can not find profession. '
end
if ['cn', 'gb'].include?(params[:language_iso])
current_user.profile.update_attribute(:country_iso, params[:language_iso])
else
error = true
flash[:alert] ||= ''
flash[:alert] << "Need select language. "
end
if params[:telephone].present?
current_user.profile.update_attribute(:phone, params[:telephone])
else
error = true
flash[:alert] ||= ''
flash[:alert] << "Need input phone number. "
end
require_additional_info = (current_user.geografic.blank? || current_user.sectors_of_interests.blank? || current_user.profession.blank? || current_user.phone.blank?)
if require_additional_info || error
redirect_to user_path(current_user) and return
else
redirect_to root_path
end
end
Первый раз я видел такое два года назад, думал, что за это время что-то поменялось в людях, неа. А вы говорите индусы