- 1
%a{href: new_user_session_path} Вход
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−103
%a{href: new_user_session_path} Вход
link_to это слишко просто
−92
errors[:please] « "fill one more field"
Ruby On Rails. Крутяк)
−80
current_time = (DateTime.parse(DateTime.now.to_s)).strftime('%d.%m.%Y %H:%M:%S')
суровые трудовыебудни
−91
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
Первый раз я видел такое два года назад, думал, что за это время что-то поменялось в людях, неа. А вы говорите индусы
−289
def self.add_zeroes(string, stringSize, leftOrRight = true)
while string.size < stringSize
string = leftOrRight ? "0" + string : string + "0"
end
string
end
−92
path = Rails.env == 'development' ? '/Users/Razumovskiy/RubymineProjects/repetitor-js/' : '/var/www/apps/repetitor2-front-end/'
−98
[1,2,3,11,12,13,14,15,17].to_a
Чтобы наверняка..
−109
def self.get_fio(l_name, f_name, s_name)
"#{l_name} #{f_name} #{s_name}"
end
В модели User
−99
if params[:back_url].try(:start_with?, '/appeals/') && params[:back_url].try(:end_with?, '/next_step')
Регулярки для лохов
−122
def contract_params
if params[:contract][:contract_type].to_i == 1
field = :contractor_id
else
field = :legal_entity_id
end
params.require(:contract).permit(
:contract_type,
:paid_expectation,
field
)
end
Much strong, very params.