-
Notifications
You must be signed in to change notification settings - Fork 58
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
Zad6 #273
base: master
Are you sure you want to change the base?
Zad6 #273
Conversation
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.
Dzięki za przesłanie rozwiązania 🎉 Działa okej 👍
class ProductsController < ApplicationController | ||
def index | ||
@customer = Customer.find(params[:customer_id]) | ||
@products = @customer.products.order(price: :desc).includes(:categories) |
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.
order
można przerzucić jako scope do modelu 😉
@@ -0,0 +1,2 @@ | |||
module ProductsHelper |
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.
niepotrzebne pliki można spokojnie usunąć 🗑
validates :name, presence: true | ||
|
||
scope :sorted, -> { order(price: :desc) } | ||
scope :cheaper_than, -> p { where('price < ?', p) } |
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.
scopy są, ale nie są nigdzie użyte 😢
No description provided.