-
Notifications
You must be signed in to change notification settings - Fork 0
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
Order #39
base: changes-after-demo
Are you sure you want to change the base?
Order #39
Conversation
@@ -6,12 +6,12 @@ def show | |||
def create | |||
end | |||
|
|||
def destroy | |||
def remove_from_cart | |||
current_user.cart.products.destroy(params[: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.
current_user.cart.products.destroy(params[:id]) | |
current_user.cart.products.destroy(params[:id]) | |
@@ -4,6 +4,62 @@ def show | |||
end | |||
|
|||
def new | |||
@order = Order.new |
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 = Order.new | |
@order = Order.new | |
if user_signed_in? | ||
@order = Order.create(status: "completed", ordered_at: Date.today, user_id: current_user.id) | ||
@address = Address.create( | ||
country: order_params[:order_detail_attributes][:address_attributes][:country], | ||
city: order_params[:order_detail_attributes][:address_attributes][:city], | ||
street: order_params[:order_detail_attributes][:address_attributes][:street], | ||
comment: order_params[:order_detail_attributes][:address_attributes][:comment], | ||
user_id: current_user.id | ||
) | ||
@order_detail = OrderDetail.create( | ||
first_name: order_params[:order_detail_attributes][:first_name], | ||
last_name: order_params[:order_detail_attributes][:last_name], | ||
email: order_params[:order_detail_attributes][:email], | ||
order_id: @order.id, | ||
address_id: @address.id | ||
) | ||
else | ||
@order = Order.create(status: "completed", ordered_at: Date.today) | ||
@address = Address.create( | ||
country: order_params[:order_detail_attributes][:address_attributes][:country], | ||
city: order_params[:order_detail_attributes][:address_attributes][:city], | ||
street: order_params[:order_detail_attributes][:address_attributes][:street], | ||
comment: order_params[:order_detail_attributes][:address_attributes][:comment] | ||
) | ||
@order_detail = OrderDetail.create( | ||
first_name: order_params[:order_detail_attributes][:first_name], | ||
last_name: order_params[:order_detail_attributes][:last_name], | ||
email: order_params[:order_detail_attributes][:email], |
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.
це виглядає максимально стрьомно, виправляй
def index | ||
flash[:success] = "Order has been successfully created!" | ||
end |
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.
а це що і нашо? видаляй
flash[:success] = "Order has been successfully created!" | ||
end | ||
|
||
private |
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.
private | |
private | |
<% end %> | ||
|
||
<%# <%= link_to "", categories_path, class: "text-xl btn-blue"%> | ||
</div> | ||
</div> | ||
</div> |
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.
де нова строка?
|
||
</div> | ||
</div> | ||
</div> |
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.
де нова строка?
resources :products | ||
delete "carts/remove_from_cart/:id", to: "carts#remove_from_cart", as: "remove_from_cart" | ||
get 'cart', to: 'carts#show', as: :cart | ||
post 'cart/:id', to: 'carts#create', as: :carts |
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.
ти там карт створюєш?
delete "products/remove_from_cart/:id", to: "products#remove_from_cart", as: "remove_from_cart" | ||
resources :categories | ||
resources :products | ||
delete "carts/remove_from_cart/:id", to: "carts#remove_from_cart", as: "remove_from_cart" |
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.
хібе патч
delete "carts/remove_from_cart/:id", to: "carts#remove_from_cart", as: "remove_from_cart" | ||
get 'cart', to: 'carts#show', as: :cart | ||
post 'cart/:id', to: 'carts#create', as: :carts | ||
delete "products/remove_from_session_cart/:id", to: "products#remove_from_session_cart", as: "remove_from_session_cart" |
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.