Skip to content
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

Open
wants to merge 5 commits into
base: changes-after-demo
Choose a base branch
from
Open

Order #39

wants to merge 5 commits into from

Conversation

kukurudz-nadia
Copy link
Owner

No description provided.

@@ -6,12 +6,12 @@ def show
def create
end

def destroy
def remove_from_cart
current_user.cart.products.destroy(params[:id])
Copy link

Choose a reason for hiding this comment

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

Suggested change
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
Copy link

Choose a reason for hiding this comment

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

Suggested change
@order = Order.new
@order = Order.new

Comment on lines +13 to +40
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],
Copy link

Choose a reason for hiding this comment

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

це виглядає максимально стрьомно, виправляй

Comment on lines +49 to +51
def index
flash[:success] = "Order has been successfully created!"
end
Copy link

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
Copy link

Choose a reason for hiding this comment

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

Suggested change
private
private

<% end %>

<%# <%= link_to "", categories_path, class: "text-xl btn-blue"%>
</div>
</div>
</div>
Copy link

Choose a reason for hiding this comment

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

де нова строка?


</div>
</div>
</div>
Copy link

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
Copy link

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"
Copy link

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"
Copy link

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