-
Notifications
You must be signed in to change notification settings - Fork 0
Items #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Items #2
Conversation
akhsunna
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в майбутньому будь уважнішим, коли називаєш класи, змінні, таблиці, поля...
| gem 'bootsnap', '>= 1.1.0', require: false | ||
|
|
||
| group :development, :test do | ||
| gem 'shrine' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а на продакшені це не знадобиться чи що?
| @@ -0,0 +1,3 @@ | |||
| # Place all the behaviors and hooks related to the matching controller here. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можна вільно видаляти такі файли, які не використовуються
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
|
||
| def configure_permitted_parameters | ||
| devise_parameter_sanitizer.permit(:sign_up, keys:[:username, :email, :password, :password_confirmation,:city_id, :remember_me]) | ||
| devise_parameter_sanitizer.permit(:sign_up, keys:[:username, :email, :password, :password_confirmation,:city_id, :remember_me, :image]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай юзати %i[] 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ye
| @@ -0,0 +1,15 @@ | |||
| require 'rails_helper' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
видаляй файли для тестів, якщо ти їх не писав там
|
|
||
| @item = Item.find(params[:item_id]) | ||
|
|
||
| @booking.total_price = (@booking.end_booking - @booking.start_booking) * (@item.price / 86_400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
чому 86_400 я не розумію?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
к-сть секунд в добі
| split(name) | ||
| =end | ||
|
|
||
| before_save :initial_rate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before_validation краще
і валідувати чи поле не пустеньке
|
|
||
| scope :by_city, ->(city_ids) { | ||
| joins(:user) | ||
| .where(users: {city_id: city_ids}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
імхо, трошки виходити за межі 80 символів (особливо в скоупах) це не так страшно, як не ставити пробіли там де треба! 🙂
| book_table = Book.arel_table | ||
| bedbooks = Book.where(book_table[:start_booking].lt(term_end) | ||
| .and(book_table[:end_booking].gt(term_start))) | ||
| Item.where.not(item_table[:id].in(bedbooks.map(&:item_id))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
якби тут було self замість Item, то ти б міг бзати це як скоуп...
| class Review < ApplicationRecord | ||
| belongs_to :reviewcontainer, polymorphic: true | ||
| include ImageUploader::Attachment.new(:image) | ||
| belongs_to :reviewcontainer, polymorphic: true, counter_cache: :review_count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надалі ніколи не забувай розділяти слова в змінних підкресленнями
review_container
| def self.average_rating | ||
| average(:rating) | ||
| end | ||
| scope :count_reviews_with_raiting, ->(raiting) { where(arel_table[:rating].eq(raiting)).count } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
краще скоупи тримати вище всіх інших методів класу
тоді їх дуже легко знайти
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
о, і це не скоуп
тут ж кількість шукається
давай юбзати скоуп тільки там, де повертається relation (масив обєктів), до якого можна застосувати інший скоуп
в цьому прекол скопів, що їх можна ланцюжком викликати, один за одним
і тут після цього ніякого іншого скоупа не викличеш, правда?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.