<%= @category.name.capitalize %>
+ +<%= link_to product.name, product_path(product.id) %>
+<%= product.description %>
+$<%= product.price / 100%>
+ +diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..469d7c26a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +# /node_modules +# /yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +# /config/master.key + + +.env + +tmp/cache/bootsnap-load-path-cache +log/development.log + +#To ignore coverage results +coverage \ No newline at end of file diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000000..25c81fe399 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.5.1 \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..5444d0fa78 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Local File", + "type": "Ruby", + "request": "launch", + "cwd": "${workspaceRoot}", + "program": "${file}" + } + ] +} diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..e7813887fd --- /dev/null +++ b/Gemfile @@ -0,0 +1,89 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.5.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.3' +# Use postgresql as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby +gem 'faker', '>= 0.3.1' + +# Use CoffeeScript for .coffee assets and views +# gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + + +gem "omniauth" +gem "omniauth-github" + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'jquery-rails' +gem 'jquery-turbolinks' +gem 'bootstrap', '~> 4.1.3' +group :development, :test do + gem 'pry-rails' +end + +group :development do + gem 'better_errors' + gem 'binding_of_caller' + gem 'guard' + gem 'guard-minitest' + gem 'dotenv-rails' +end + +group :test do + gem 'minitest-rails' + gem 'minitest-reporters' +end + +gem 'simplecov', require: false, group: :test \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..2f6548b287 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,318 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.3) + actionpack (= 5.2.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.3) + actionview (= 5.2.3) + activesupport (= 5.2.3) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.3) + activesupport (= 5.2.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.3) + activesupport (= 5.2.3) + globalid (>= 0.3.6) + activemodel (5.2.3) + activesupport (= 5.2.3) + activerecord (5.2.3) + activemodel (= 5.2.3) + activesupport (= 5.2.3) + arel (>= 9.0) + activestorage (5.2.3) + actionpack (= 5.2.3) + activerecord (= 5.2.3) + marcel (~> 0.3.1) + activesupport (5.2.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) + ansi (1.5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + autoprefixer-rails (9.5.1) + execjs + better_errors (2.5.1) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) + bindex (0.7.0) + binding_of_caller (0.8.0) + debug_inspector (>= 0.0.1) + bootsnap (1.4.4) + msgpack (~> 1.0) + bootstrap (4.1.3) + autoprefixer-rails (>= 6.0.3) + popper_js (>= 1.12.9, < 2) + sass (>= 3.5.2) + builder (3.2.3) + byebug (11.0.1) + capybara (3.18.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) + childprocess (1.0.1) + rake (< 13.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.2) + concurrent-ruby (1.1.5) + crass (1.0.4) + debug_inspector (0.0.3) + docile (1.3.1) + dotenv (2.7.2) + dotenv-rails (2.7.2) + dotenv (= 2.7.2) + railties (>= 3.2, < 6.1) + erubi (1.8.0) + execjs (2.7.0) + faker (1.9.3) + i18n (>= 0.7) + faraday (0.15.4) + multipart-post (>= 1.2, < 3) + ffi (1.10.0) + formatador (0.2.5) + globalid (0.4.2) + activesupport (>= 4.2.0) + guard (2.15.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-minitest (2.4.6) + guard-compat (~> 1.2) + minitest (>= 3.0) + hashie (3.6.0) + i18n (1.6.0) + concurrent-ruby (~> 1.0) + io-like (0.3.0) + jbuilder (2.8.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + jquery-turbolinks (2.1.0) + railties (>= 3.1.0) + turbolinks + json (2.1.0) + jwt (2.1.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.2.3) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + lumberjack (1.0.13) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.1) + mini_portile2 (2.4.0) + minitest (5.11.3) + minitest-rails (3.0.0) + minitest (~> 5.8) + railties (~> 5.0) + minitest-reporters (1.3.6) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + msgpack (1.2.10) + multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nenv (0.3.0) + nio4r (2.3.1) + nokogiri (1.10.3) + mini_portile2 (~> 2.4.0) + notiffany (0.1.1) + nenv (~> 0.1) + shellany (~> 0.0) + oauth2 (1.4.1) + faraday (>= 0.8, < 0.16.0) + jwt (>= 1.0, < 3.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) + omniauth (1.9.0) + hashie (>= 3.4.6, < 3.7.0) + rack (>= 1.6.2, < 3) + omniauth-github (1.3.0) + omniauth (~> 1.5) + omniauth-oauth2 (>= 1.4.0, < 2.0) + omniauth-oauth2 (1.6.0) + oauth2 (~> 1.1) + omniauth (~> 1.9) + pg (1.1.4) + popper_js (1.14.5) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (3.0.3) + puma (3.12.1) + rack (2.0.7) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.3) + actioncable (= 5.2.3) + actionmailer (= 5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + activemodel (= 5.2.3) + activerecord (= 5.2.3) + activestorage (= 5.2.3) + activesupport (= 5.2.3) + bundler (>= 1.3.0) + railties (= 5.2.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.2.3) + actionpack (= 5.2.3) + activesupport (= 5.2.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (12.3.2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + regexp_parser (1.4.0) + ruby-progressbar (1.10.0) + ruby_dep (1.5.0) + rubyzip (1.2.2) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.0) + childprocess (>= 0.5, < 2.0) + rubyzip (~> 1.2, >= 1.2.2) + shellany (0.0.1) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + spring (2.0.2) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.9) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.1.20) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + better_errors + binding_of_caller + bootsnap (>= 1.1.0) + bootstrap (~> 4.1.3) + byebug + capybara (>= 2.15) + chromedriver-helper + dotenv-rails + faker (>= 0.3.1) + guard + guard-minitest + jbuilder (~> 2.5) + jquery-rails + jquery-turbolinks + listen (>= 3.0.5, < 3.2) + minitest-rails + minitest-reporters + omniauth + omniauth-github + pg (>= 0.18, < 2.0) + pry-rails + puma (~> 3.11) + rails (~> 5.2.3) + sass-rails (~> 5.0) + selenium-webdriver + simplecov + spring + spring-watcher-listen (~> 2.0.0) + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.5.1p57 + +BUNDLED WITH + 2.0.1 diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000000..e34f706f4a --- /dev/null +++ b/Guardfile @@ -0,0 +1,9 @@ +guard :minitest, autorun: false, spring: true do + watch(%r{^app/(.+).rb$}) { |m| "test/#{m[1]}_test.rb" } + watch(%r{^app/controllers/application_controller.rb$}) { 'test/controllers' } + watch(%r{^app/controllers/(.+)_controller.rb$}) { |m| "test/integration/#{m[1]}_test.rb" } + watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" } + watch(%r{^lib/(.+).rb$}) { |m| "test/lib/#{m[1]}_test.rb" } + watch(%r{^test/.+_test.rb$}) + watch(%r{^test/test_helper.rb$}) { 'test' } +end diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..e85f913914 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000000..b16e53d6d5 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/images/favicon.ico b/app/assets/images/favicon.ico new file mode 100644 index 0000000000..e45288fe1f Binary files /dev/null and b/app/assets/images/favicon.ico differ diff --git a/app/assets/images/goldceiling.jpg b/app/assets/images/goldceiling.jpg new file mode 100644 index 0000000000..5600730916 Binary files /dev/null and b/app/assets/images/goldceiling.jpg differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000000..4f73c21a7d --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,20 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's +// vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. + //= require jquery3 + //= require popper + //= require bootstrap-sprockets + +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 0000000000..739aa5f022 --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/categories.js b/app/assets/javascripts/categories.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/categories.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/javascripts/home_page.js b/app/assets/javascripts/home_page.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/home_page.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/merchants.js b/app/assets/javascripts/merchants.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/merchants.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/order_items.js b/app/assets/javascripts/order_items.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/order_items.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/orders.js b/app/assets/javascripts/orders.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/orders.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/products.js b/app/assets/javascripts/products.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/products.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/reviews.js b/app/assets/javascripts/reviews.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/reviews.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 0000000000..22cbfa7648 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1,192 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + */ + +/* Custom bootstrap variables must be set or imported *before* bootstrap. */ +@import "bootstrap"; +/* Import scss content */ +@import "**/*"; + +.app-header__nav { + display: flex; + flex-direction: row; + justify-content: space-between; +} + +.app-header__nav_item { + margin-top: 1rem; + color: #310A31; +} + +.btn-primary { + color: black; + background-color: #ffffff; + border-color: #ffffff; +} + +.dropdown-menu { + text-align: center; + color: black; + background-color: #ffffff; + border-color: #ffffff; +} + + +.btn-primary:hover { + color: #ffffff; + background-color: #310A31; + border-color: black; +} + +.nav-link { + color: #ffffff; +} + +.navbar-nav .nav-link { + padding-right: 0; + padding-left: 0; +} + +.nav-link:hover { + color: black; +} + +h1 a { + color: #FFF9D4; +} + +h1 a:hover { + color: black; + text-decoration: none; +} + +body { + background-color: #F6F7EB; +} + +.navbar-custom { + background: white; +} + +.fixed-top { + position: fixed; + top: 0; + right: 0; + left: 0; + z-index: 1030; +} + +.navbar-expand-lg { + flex-flow: row nowrap; + justify-content: flex-start; +} + +.navbar { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + padding: 0.5rem 1rem; +} +.navbar a { + color: #4f5d75; + font-family: 'Roboto', Sans-Serif !important; +} +.navbar-brand { + color: #310A31 !important; + display: inline-block; + padding-top: 0.3125rem; + padding-bottom: 0.3125rem; + margin-right: 23rem; + font-size: 2rem !important; + line-height: inherit; + white-space: nowrap; +} + +.app-carousel-container { + width: 100%; + display: inline-block; +} +.w-100 { + width: 100% !important; +} + +ul{ + list-style: none; +} + +img { + vertical-align: middle; + border-style: none; +} + +.carousel-text { + color: white; + padding: 0; + margin: 0; + font-weight: bold; + font-size: 6rem; + text-shadow: 2px 2px #2d3142; + padding-bottom: 12rem; +} + +h1 { + font-family: 'Roboto', Sans-Serif; + font-weight: bold; + font-size: 5rem; + color: #2d3142; + text-align: center; + padding-bottom: 5rem; +} + +.card-deck { + justify-content: right; + width: 100%; + max-width: 100%; + margin: 0; +} + + +#prod-deck .card { + flex-basis: 18rem; + margin-top: 1rem; +} + + +#cat-prod-deck .card { + flex-basis: 18rem; + margin-top: 1rem; +} + + +#merch-prod-deck .card { + flex-basis: 18rem; + margin-top: 1rem; +} + +.footer-copyright { + color: #fff; + font-family: 'Lora', Sans-Serif; + height: 20rem; +} + +footer, .text-uppercase { + background-color: #310A31; + color: #fff; + font-family: 'Roboto', Sans-Serif; +} + +footer { + margin-top: 10rem; + width: 100%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/categories.scss b/app/assets/stylesheets/categories.scss new file mode 100644 index 0000000000..ff5d593bab --- /dev/null +++ b/app/assets/stylesheets/categories.scss @@ -0,0 +1,7 @@ +// Place all the styles related to the Categories controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.card{ + list-style: none; +} \ No newline at end of file diff --git a/app/assets/stylesheets/home_page.scss b/app/assets/stylesheets/home_page.scss new file mode 100644 index 0000000000..99f237c9ac --- /dev/null +++ b/app/assets/stylesheets/home_page.scss @@ -0,0 +1,12 @@ +// Place all the styles related to the home-page controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.alert { + position: relative; + padding: 0.75rem 1.25rem; + margin-bottom: 1rem; + border: 1px solid transparent; + border-radius: 0.25rem; + width: 100%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/merchants.scss b/app/assets/stylesheets/merchants.scss new file mode 100644 index 0000000000..f4c164d600 --- /dev/null +++ b/app/assets/stylesheets/merchants.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Merchants controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/order_items.scss b/app/assets/stylesheets/order_items.scss new file mode 100644 index 0000000000..584862de9b --- /dev/null +++ b/app/assets/stylesheets/order_items.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the OrderItems controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/orders.scss b/app/assets/stylesheets/orders.scss new file mode 100644 index 0000000000..741506954d --- /dev/null +++ b/app/assets/stylesheets/orders.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Orders controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/products.scss b/app/assets/stylesheets/products.scss new file mode 100644 index 0000000000..d83b026ffd --- /dev/null +++ b/app/assets/stylesheets/products.scss @@ -0,0 +1,57 @@ +// Place all the styles related to the Products controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +div { + display: block; +} + +.jumbotron-fluid h1 { + color: white; + text-shadow: 2px 2px #2d3142; + font-size: 5rem; + font-weight: bold; + padding-top: 1rem; + display: inline-block; + width: 100%; +} +.display-4 { + font-size: 3.5rem; + font-weight: 300; + line-height: 1.2; +} +h1 { + font-family: 'Roboto', Sans-Serif; + font-weight: bold; + font-size: 5rem; + color: #2d3142; + text-align: center; + padding-bottom: 5rem; +} + +.jumbotron-fluid { + margin-top: 1rem; + background-image: url(https://live.staticflickr.com/5592/14882087562_3feb759208_c.jpg://live.staticflickr.com/5173/5451575773_160aff7cd4.jpg); + background-size: cover; +} +.product-details-container { + display: grid; + grid-template-columns: 1fr 1fr; + grid-template-rows: 1fr; + grid-column-gap: 2rem; + margin-top: 7rem; + margin-right: 7rem; + margin-left: 5rem; +} + +.add-review-container { + display: flex; + flex-direction: column; + margin: 7rem; + justify-content: center; + border-top: 2px solid lightgray; + padding-top: 1rem; +} + +.product-review-container ul{ + list-style-type: none; +} \ No newline at end of file diff --git a/app/assets/stylesheets/reviews.scss b/app/assets/stylesheets/reviews.scss new file mode 100644 index 0000000000..11bbb12cd5 --- /dev/null +++ b/app/assets/stylesheets/reviews.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Reviews controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 0000000000..d672697283 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 0000000000..0ff5442f47 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000000..ff6730eb54 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,15 @@ +class ApplicationController < ActionController::Base + before_action :find_merchant + + def find_merchant + @current_merchant = Merchant.find_by(id: session[:merchant_id]) + end + + def require_login + current_user = find_merchant + if current_user.nil? + flash[:error_form] = "You must be logged in to do this action" + redirect_to root_path + end + end +end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb new file mode 100644 index 0000000000..029a524dc5 --- /dev/null +++ b/app/controllers/categories_controller.rb @@ -0,0 +1,35 @@ +class CategoriesController < ApplicationController + before_action :require_login, only: [:index, :new, :create] + + def index + @categories = Category.all + end + + def show + @category = Category.find_by(id: params[:id]) + end + + def new + @category = Category.new(name: "Default category name") + end + + def create + category = Category.new(category_params) + + is_successful = category.save + + if is_successful + flash[:success] = "Category successfully created" + redirect_to categories_path + else + category.errors.messages.each do |field, messages| + flash.now[field] = messages + end + render :new, status: :bad_request + end + end + + def category_params + return params.require(:category).permit(:name) + end +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/controllers/home_page_controller.rb b/app/controllers/home_page_controller.rb new file mode 100644 index 0000000000..9af835aec9 --- /dev/null +++ b/app/controllers/home_page_controller.rb @@ -0,0 +1,2 @@ +class HomePageController < ApplicationController +end diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb new file mode 100644 index 0000000000..11b265e10f --- /dev/null +++ b/app/controllers/merchants_controller.rb @@ -0,0 +1,57 @@ +class MerchantsController < ApplicationController + def index + @merchants = Merchant.all.order(:id) + end + + def show + @merchant = Merchant.find_by(id: params[:id]) + + if @merchant.nil? + flash[:error] = "Unknown merchant" + redirect_to merchants_path + end + end + + def create + auth_hash = request.env["omniauth.auth"] + + merchant = Merchant.find_by(uid: auth_hash[:uid], provider: "github") + + if merchant + flash[:success] = "Logged in as a returning merchant #{merchant.username}" + else + merchant = Merchant.build_from_github(auth_hash) + + if merchant.save + flash[:success] = "Logged in as new merchant #{merchant.username}" + else + flash[:error] = "Could not create new merchant account: #{merchant.errors.messages}" + return redirect_to root_path + end + end + + session[:merchant_id] = merchant.id + + return redirect_to root_path + end + + def current + @merchant = Merchant.find_by(id: session[:merchant_id]) + if @merchant.nil? + flash[:error] = "You must be logged in first!" + redirect_to root_path + end + end + + def dashboard + @merchant = Merchant.find_by(id: session[:merchant_id]) + end + + def logout + merchant = Merchant.find_by(id: session[:merchant_id]) + + session[:merchant_id] = nil + flash[:success] = "Successfully logged out, #{merchant.username}!" + redirect_to root_path + end +end diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb new file mode 100644 index 0000000000..d229966559 --- /dev/null +++ b/app/controllers/order_items_controller.rb @@ -0,0 +1,111 @@ +class OrderItemsController < ApplicationController + def create + if session[:merchant_id] + flash[:error] = "Log out of your merchant account to shop!" + redirect_to products_path + else + if session[:order_id] + order = Order.find(session[:order_id]) + else + order = Order.create + session[:order_id] = order.id + end + + product = Product.find_by(id: params[:product_id]) + quantity = params[:quantity].to_i + + if product.available_inventory?(quantity) + if order.add_product_to_cart!(product, quantity) + flash[:success] = "Item added to Cart" + return redirect_to products_path + else + flash[:error] = "Could not add item to Cart" + return redirect_to root_path + end + else + flash[:error] = "Not enough #{product.name} in stock" + return redirect_to product_path(product.id) + end + end + end + + def update + order_item = Orderitem.find_by(id: params[:id]) + + if order_item.nil? + flash[:error] = "Order item not found" + return redirect_to products_path + end + + + requested_quantity = params[:quantity].to_i + adjusted_quantity = order_item.adjust_quantity_by!(requested_quantity) + + if requested_quantity != adjusted_quantity + flash[:error] = "Not enough #{order_item.product.name} in stock" + end + + redirect_to order_path(order_item.order) + end + + def destroy + @order_item = Orderitem.find_by(id: params[:id]) + @order = Order.find_by(id: @order_item.order_id) + product = Product.find_by(id: @order_item.product_id) + + if @order_item.nil? + flash[:error] = "This order item does not exist" + else + returned_inventory = (product.inventory + @order_item.quantity) + product.update(inventory: returned_inventory) + + deleted_orders = Orderitem.where(product_id: @order_item.product_id) + + deleted_orders.each do |delete_order| + delete_order.destroy + end + + flash[:success] = "Item removed from Cart" + redirect_to order_path(@order.id) + end + end + + def random_create + order = Order.find(session[:order_id]) + + @order_item = Orderitem.create(quantity: 1, product_id: Product.all.sample.id, order_id: order.id) + + random_product = Product.find_by(id: @order_item.product_id) + random_product.update(inventory: (random_product.inventory - 1)) + + order.orderitems << @order_item + return redirect_to order_path(order.id) + end + + def shipment + @order_item = Orderitem.find_by(id: params[:id]) + if @order_item.nil? + flash[:error] = "Order item does not exist" + else + @order_item.toggle!(:status) + + unshipped_order = 0 + + current_order = Order.find_by(id: @order_item.order_id) + order_count = current_order.orderitems.length + + current_order.orderitems.each do |order_item| + if order_item.status == false + unshipped_order += 1 + end + end + + if unshipped_order == 0 + current_order.update(status: "completed") + elsif unshipped_order <= order_count + current_order.update(status: "paid") + end + end + redirect_back(fallback_location: dashboard_orders_path) + end +end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb new file mode 100644 index 0000000000..8141210acb --- /dev/null +++ b/app/controllers/orders_controller.rb @@ -0,0 +1,52 @@ +class OrdersController < ApplicationController + def show + @order = Order.find_by(id: params[:id]) + + if @order.nil? + flash[:error] = "Unfound order" + + redirect_to root_path + end + end + + def edit + @order = Order.find_by(id: session[:order_id]) + end + + def update + @order = Order.find_by(id: session[:order_id]) + @order.status = "paid" + is_successful = @order.update(order_params) + + if is_successful + flash[:success] = "Thank you for placing your order!" + redirect_to receipt_path(@order.id) + else + @order.errors.messages.each do |field, messages| + flash.now[field] = messages + end + render :edit, status: :bad_request + end + end + + def cancel + @order = Order.find_by(id: session[:order_id]) + @order.status = "cancelled" + @order.save + session[:order_id] = nil + flash[:success] = "This order has been cancelled" + + redirect_to root_path + end + + def receipt + @order = Order.find_by(id: params[:id]) + session[:order_id] = nil + end + + private + + def order_params + return params.require(:order).permit(:name, :email, :address, :cc_num, :cc_exp, :cc_cvv, :billing_zip, :status) + end +end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 0000000000..83db94180c --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,83 @@ +class ProductsController < ApplicationController + before_action :require_login, only: [:new, :create, :edit, :update, :retired] + before_action :find_product, only: [:show, :edit, :update, :retired] + + def index + @products = Product.all + end + + def show + if @product.nil? + flash[:error] = "Unknown product" + + redirect_to products_path + end + end + + def new + @product = Product.new + end + + def create + product = Product.new(product_params) + #the instance variable @current_merchant is included in the body of the response from Github when a merchant signs in + product.merchant = @current_merchant + + is_successful = product.save + + if is_successful + flash[:success] = "Product added successfully" + redirect_to dashboard_path(product.merchant.id) + else + product.errors.messages.each do |field, messages| + flash.now[field] = messages + end + + render :new, status: :bad_request + end + end + + def edit + if @product.nil? + head :not_found + end + end + + def update + if @product.nil? + head :not_found + else + is_successful = @product.update(product_params) + if is_successful + flash[:success] = "Product updated successfully" + redirect_to product_path(@product.id) + else + @product.errors.messages.each do |field, messages| + flash.now[field] = messages + end + render :edit, status: :bad_request + end + end + end + + def retired + if @product.nil? + flash[:error] = "Product does not exist" + else + @product.toggle(:retired) + @product.save + end + + redirect_back(fallback_location: products_path) + end + + private + + def find_product + @product = Product.find_by(id: params[:id]) + end + + def product_params + return params.require(:product).permit(:name, :price, :description, :photo, :inventory, category_ids: []) + end +end diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb new file mode 100644 index 0000000000..c861cf5369 --- /dev/null +++ b/app/controllers/reviews_controller.rb @@ -0,0 +1,45 @@ +class ReviewsController < ApplicationController + def new + current_product_id = params[:product_id].to_i + #if the merchant is locked in, check if any of the products belong to the merchant is the one getting reviewed + if !@current_merchant.nil? + if @current_merchant.product_ids.include? current_product_id + flash[:error] = "You can't review your own product" + redirect_to product_path(params[:product_id]) + end + else + @review = Review.new + end + end + + def create + review = Review.new(review_params) + #If the reviewer does not enter their name then assign their name to anonymous + if review.reviewer == "" + review.reviewer = "Anonymous" + end + + review.product_id = Product.find_by(id: params[:product_id]).id + + if review.save + flash[:success] = "Review successfully posted" + redirect_to product_path(review.product_id) + else + review.errors.messages.each do |field, messages| + flash.now[field] = messages + end + + render :new, status: :bad_request + end + end + + private + + def review_params + if !@current_merchant.nil? + return params.permit(:reviewer, :rating, :description, :product_id) + else + return params.require(:review).permit(:reviewer, :rating, :description, :product_id) + end + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000000..de6be7945c --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb new file mode 100644 index 0000000000..e06f31554c --- /dev/null +++ b/app/helpers/categories_helper.rb @@ -0,0 +1,2 @@ +module CategoriesHelper +end diff --git a/app/helpers/home_page_helper.rb b/app/helpers/home_page_helper.rb new file mode 100644 index 0000000000..363d843fff --- /dev/null +++ b/app/helpers/home_page_helper.rb @@ -0,0 +1,2 @@ +module HomePageHelper +end diff --git a/app/helpers/merchants_helper.rb b/app/helpers/merchants_helper.rb new file mode 100644 index 0000000000..5337747b0f --- /dev/null +++ b/app/helpers/merchants_helper.rb @@ -0,0 +1,2 @@ +module MerchantsHelper +end diff --git a/app/helpers/order_items_helper.rb b/app/helpers/order_items_helper.rb new file mode 100644 index 0000000000..e197528ae1 --- /dev/null +++ b/app/helpers/order_items_helper.rb @@ -0,0 +1,2 @@ +module OrderItemsHelper +end diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb new file mode 100644 index 0000000000..443227fd48 --- /dev/null +++ b/app/helpers/orders_helper.rb @@ -0,0 +1,2 @@ +module OrdersHelper +end diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb new file mode 100644 index 0000000000..ab5c42b325 --- /dev/null +++ b/app/helpers/products_helper.rb @@ -0,0 +1,2 @@ +module ProductsHelper +end diff --git a/app/helpers/reviews_helper.rb b/app/helpers/reviews_helper.rb new file mode 100644 index 0000000000..682b7b1abc --- /dev/null +++ b/app/helpers/reviews_helper.rb @@ -0,0 +1,2 @@ +module ReviewsHelper +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000000..a009ace51c --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000000..286b2239d1 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000000..10a4cba84d --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 0000000000..0306f0cf69 --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,5 @@ +class Category < ApplicationRecord + has_and_belongs_to_many :products + + validates :name, presence: true +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/models/merchant.rb b/app/models/merchant.rb new file mode 100644 index 0000000000..5acf0965b3 --- /dev/null +++ b/app/models/merchant.rb @@ -0,0 +1,68 @@ +class Merchant < ApplicationRecord + has_many :products + + validates :username, presence: true, uniqueness: true + validates :email, presence: true, uniqueness: true + + def self.build_from_github(auth_hash) + merchant = Merchant.new + merchant.uid = auth_hash[:uid] + merchant.provider = "github" + merchant.name = auth_hash["info"]["name"] + merchant.username = auth_hash["info"]["nickname"] + merchant.email = auth_hash["info"]["email"] + return merchant + end + + def self.find_order_items(merchant, status) + orders = [] + + if merchant.class == Merchant + products = merchant.products + products.each do |product| + order_items = Orderitem.find_order_items_by_product(product) + if status == "all" + statuses = ["completed", "paid", "cancelled"] + statuses.each do |s| + order_items.each do |order_item| + if order = find_order_by_status(order_item, s) + orders << order_item + end + end + end + else + order_items.each do |order_item| + if order = find_order_by_status(order_item, status) + orders << order_item + end + end + end + end + end + + return orders.sort! + end + + def self.find_order_by_status(order_item, status) + order = Order.find_by(id: order_item.order_id) + if order.status == status + return order + else + return false + end + end + + def self.calculate_subtotal(order_item) + if order_item.class == Orderitem + subtotal_cents = 0 + subtotal_cents += order_item.quantity * order_item.product.price + subtotal = subtotal_cents / 100.00 + return subtotal + end + return false + end + + def self.show_all_products(merchant) + return products = merchant.products + end +end diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 0000000000..02f61bb6b0 --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,53 @@ +class Order < ApplicationRecord + has_many :orderitems + + def cart + itemized_cart = {} + quantity = 0 + + self.orderitems.each do |order_item| + itemized_cart[order_item] = quantity + order_item.quantity + end + + final_cart = Hash.new(0) + + itemized_cart.each do |order_item, quantity| + final_cart[Orderitem.find_by(product_id: order_item.product_id)] += quantity + end + + return final_cart + end + + def cart_total + cart_total = 0 + + self.orderitems.each do |order_item| + cart_total += order_item.subtotal + end + + return cart_total + end + + def add_product_to_cart!(product, quantity) + order_item = self.orderitems.create(quantity: quantity, product: product) + + if !order_item.id.nil? + product.reduce_inventory_by!(quantity) + return order_item + end + + return nil + end + + def shipped_items + if self.status != "complete" + shipped_items = 0 + self.orderitems.each do |order_item| + if order_item.status == true + shipped_items += 1 + end + end + return shipped_items + end + end +end diff --git a/app/models/orderitem.rb b/app/models/orderitem.rb new file mode 100644 index 0000000000..429836ff66 --- /dev/null +++ b/app/models/orderitem.rb @@ -0,0 +1,32 @@ +class Orderitem < ApplicationRecord + belongs_to :product + belongs_to :order + + validates :quantity, presence: true, numericality: {greater_than: 0} + + def subtotal + return self.quantity * (Product.find_by(id: self.product_id).price / 100) + end + + def adjust_quantity_by!(requested_quantity) + adjusted_quantity = self.product.adjust_inventory_by!(self.quantity, requested_quantity) + + if self.quantity != adjusted_quantity + self.update(quantity: adjusted_quantity) + end + + return adjusted_quantity + end + + def self.find_order_items_by_product(product) + where(product_id: product.id) + end + + def self.display_shipment(order_item) + if order_item.status? + return "Yes" + else + return "Not yet" + end + end +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 0000000000..8e2576ebf9 --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,34 @@ +class Product < ApplicationRecord + belongs_to :merchant + has_many :reviews + has_many :orderitems + has_and_belongs_to_many :categories + + validates :name, presence: true, uniqueness: true + validates :price, presence: true, numericality: {only_integer: true, greater_than: 0} + + def self.browse_by_category(category) + joins(:categories).where(categories: {id: category.id}).distinct + end + + def available_inventory?(quantity) + return self.inventory >= quantity + end + + def reduce_inventory_by!(quantity) + new_inventory = (self.inventory - quantity) + + self.update(inventory: new_inventory) + end + + def adjust_inventory_by!(prev_quantity, requested_quantity) + available_quantity = self.inventory + prev_quantity + + if requested_quantity > available_quantity + return prev_quantity + else + self.update(inventory: available_quantity - requested_quantity) + return requested_quantity + end + end +end diff --git a/app/models/review.rb b/app/models/review.rb new file mode 100644 index 0000000000..ad6e6d0de3 --- /dev/null +++ b/app/models/review.rb @@ -0,0 +1,23 @@ +class Review < ApplicationRecord + belongs_to :product + + validates :rating, presence: true, numericality: {only_integer: true}, inclusion: {in: 1..5} + + def self.average_rating(product) + if product.reviews.length == 0 + return average_rating = 0 + else + rating_sum = 0 + rating_count = product.reviews.length + reviews_array = product.reviews + + reviews_array.each do |review| + rating_sum += review.rating + end + + average_rating = rating_sum / rating_count + end + return average_rating + end + +end diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb new file mode 100644 index 0000000000..f7236889f4 --- /dev/null +++ b/app/views/categories/_form.html.erb @@ -0,0 +1,11 @@ +
+<%= form_with model: @category do |f| %> + +<%= f.label :name %> +<%= f.text_field :name %> + +<%= f.submit class: "btn btn-primary" %> + +<% end %> + + \ No newline at end of file diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb new file mode 100644 index 0000000000..2ec6c4cde1 --- /dev/null +++ b/app/views/categories/index.html.erb @@ -0,0 +1,12 @@ +<%= product.description %>
+$<%= product.price / 100%>
+ +