Яuбy / Говнокод #17885 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 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

Первый раз я видел такое два года назад, думал, что за это время что-то поменялось в людях, неа. А вы говорите индусы

Запостил: Ignat_Z Ignat_Z, (Updated )

Комментарии (4) RSS

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8