-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from rauversion/products
Products
- Loading branch information
Showing
259 changed files
with
5,924 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# lib/generators/backstage/templates/controller.rb | ||
module Backstage | ||
class CategoriesController < Backstage::BaseController | ||
|
||
def model_class | ||
Category | ||
end | ||
|
||
def permitted_params | ||
params.require(:user).permit(:email, :username, :role, :editor) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# lib/generators/backstage/templates/controller.rb | ||
module Backstage | ||
class PostsController < Backstage::BaseController | ||
# Add any resource-specific logic here | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/controllers/backstage/terms_and_conditions_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# lib/generators/backstage/templates/controller.rb | ||
module Backstage | ||
class TermsAndConditionsController < Backstage::BaseController | ||
def model_class | ||
TermsAndCondition | ||
end | ||
|
||
def permitted_params | ||
params.require(:user).permit(:email, :username, :role, :editor) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# lib/generators/backstage/templates/controller.rb | ||
module Backstage | ||
class UsersController < Backstage::BaseController | ||
|
||
def model_class | ||
User | ||
end | ||
|
||
def permitted_params | ||
params.require(:user).permit(:email, :username, :role, :editor) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# app/controllers/product_cart_controller.rb | ||
class ProductCartController < ApplicationController | ||
include ApplicationHelper # This gives us access to the current_cart method | ||
before_action :set_cart | ||
|
||
def add | ||
product = Product.find(params[:product_id]) | ||
@cart.add_product(product) | ||
redirect_back(fallback_location: root_path, notice: 'Item added to cart') | ||
end | ||
|
||
def show | ||
@cart_items = @cart.product_cart_items.includes(:product) | ||
end | ||
|
||
def remove | ||
item = @cart.product_cart_items.find_by(product_id: params[:product_id]) | ||
item.destroy if item | ||
redirect_to( product_cart_path, notice: 'Item removed from cart') | ||
end | ||
|
||
private | ||
|
||
def set_cart | ||
@cart = current_cart | ||
if @cart.blank? | ||
redirect_to root_path, notice: "Log in first to access your cart" and return | ||
end | ||
end | ||
end |
Oops, something went wrong.