Skip to content

Conversation

@RomanSipyak
Copy link
Owner

No description provided.

Copy link

@akhsunna akhsunna left a 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'

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можна вільно видаляти такі файли, які не використовуються

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

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])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай юзати %i[] 🙂

Copy link
Owner Author

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'

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

чому 86_400 я не розумію?

Copy link
Owner Author

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

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})

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)))

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

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 }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

краще скоупи тримати вище всіх інших методів класу
тоді їх дуже легко знайти

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

о, і це не скоуп
тут ж кількість шукається
давай юбзати скоуп тільки там, де повертається relation (масив обєктів), до якого можна застосувати інший скоуп
в цьому прекол скопів, що їх можна ланцюжком викликати, один за одним
і тут після цього ніякого іншого скоупа не викличеш, правда?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants