This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.set_range(date = 26) | |
range = Range.new | |
if Date.today.strftime('%d') < date | |
start_date = Date.new((Date.today - 1.month).strftime('%Y').to_i,(Date.today - 1.month).strftime('%m').to_i, 26) | |
end_date = Date.new((Date.today).strftime('%Y').to_i,(Date.today).strftime('%m').to_i, 26) | |
range = start_date..end_date | |
else | |
end | |
range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. In the previous code, everything is fine. You can order you records by adding order method and send it field (id). | |
class User < ActiveRecord::Base | |
scope :find_by_age, ->(age) { where("users.age = #{age}").order(:id) } | |
end | |
2.I assume that the developer incorrectly calculates the number of posts. If a user has a large number of posts, we need to add a callbacks to posts model. In this callbacks we will be increment or decrement users field posts_count. And when we will be call search we can increase our perfomance. | |
3. Write test for | |
class Message | |
def mark_as_read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="modalbox" id="modalbox"> | |
<div class="close"><p>X</p></div> | |
<h2 style="text-align: center;">Заказ звонка</h2> | |
<form id="myform"> | |
<input type="text" class="youname" name="name" placeholder="Ваше имя" onblur="if (this.placeholder=='') this.placeholder='Ваше имя';" onfocus="if (this.placeholder=='Ваше имя') this.placeholder='';"> | |
<input class="youphone" name="phone" placeholder="Ваш телефон" onblur="if (this.placeholder=='') this.placeholder='Ваш телефон';" onfocus="if (this.placeholder=='Ваш телефон') this.placeholder='';"> | |
<input type="email" class="youname" name="email" placeholder="Ваш email" onblur="if (this.placeholder=='') this.placeholder='Ваш email';" onfocus="if (this.placeholder=='Ваш email') this.placeholder='';"> | |
<input type="submit" value="ОТПРАВИТЬ"> | |
</form> | |
<div id="thankyou"><p>Спасибо, мы перезвоним</p></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Language | |
AVAILABLE_LANGUAGE = ['en', 'ru'] | |
LANGUAGE = { | |
DEFAULT: 'en', | |
RU: 'ru', | |
EN: 'en' | |
} | |
def t(key) | |
translation = Translation.where(key: key).first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Constant | |
class User | |
def self.ZODIAC | |
if Language.get_language == 'ru' | |
%w[Овен Лев Стрелец Телец Дева Козерог Близнецы Весы Водолей Рак Скорпион Рыба] | |
else | |
%w[Aries Leo Sagittarius Taurus Virgo Capricorn Gemini Libra Aquarius Cancer Scorpio Pisces] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Language | |
AVAILABLE_LANGUAGE = ['en', 'ru'] | |
LANGUAGE = { | |
DEFAULT: 'en', | |
RU: 'ru', | |
EN: 'en' | |
} | |
def t(key) | |
translation = Translation.where(key: key).first |
NewerOlder