├── final ├── log │ └── .keep ├── app │ ├── mailers │ │ ├── .keep │ │ ├── application_mailer.rb │ │ └── order_mailer.rb │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ ├── address.rb │ │ ├── cart_item.rb │ │ ├── line_item.rb │ │ ├── product.rb │ │ └── catalog.rb │ ├── assets │ │ ├── images │ │ │ ├── .keep │ │ │ ├── logo.png │ │ │ └── favicon.ico │ │ ├── javascripts │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ ├── bootstrap.js.coffee │ │ │ ├── simplex.js │ │ │ └── cerulean.js │ │ └── stylesheets │ │ │ ├── simplex │ │ │ └── custom.less │ │ │ ├── simplex.css │ │ │ └── cerulean.css │ ├── controllers │ │ ├── concerns │ │ │ └── .keep │ │ ├── admin │ │ │ ├── base_controller.rb │ │ │ └── home_controller.rb │ │ └── admins_controller.rb │ ├── views │ │ ├── admin │ │ │ └── home │ │ │ │ └── index.html.erb │ │ ├── application │ │ │ ├── _flash.html.erb │ │ │ ├── _footer.html.haml │ │ │ └── _footer.html │ │ ├── products │ │ │ ├── destroy.js.erb │ │ │ ├── show.json.jbuilder │ │ │ ├── update.json.jbuilder │ │ │ ├── index.json.jbuilder │ │ │ ├── edit.html.erb │ │ │ └── new.html.erb │ │ ├── orders │ │ │ ├── show.json.jbuilder │ │ │ ├── new.html.erb │ │ │ ├── index.json.jbuilder │ │ │ └── edit.html.erb │ │ ├── order_mailer │ │ │ ├── confirm_email.text.erb │ │ │ └── confirm_email.html.erb │ │ ├── variants │ │ │ ├── show.json.jbuilder │ │ │ ├── new.html.erb │ │ │ ├── edit.html.erb │ │ │ └── index.json.jbuilder │ │ ├── layouts │ │ │ └── mailer.text.erb │ │ ├── home │ │ │ └── index.html.erb │ │ └── devise │ │ │ └── mailer │ │ │ └── confirmation_instructions.html.erb │ ├── helpers │ │ ├── home_helper.rb │ │ ├── orders_helper.rb │ │ ├── products_helper.rb │ │ ├── variants_helper.rb │ │ └── application_helper.rb │ └── jobs │ │ └── order_create_job.rb ├── config │ ├── deploy.rb │ ├── puma.rb │ ├── locales │ │ ├── zh-CN.yml │ │ └── models │ │ │ └── order │ │ │ └── zh-CN.yml │ ├── initializers │ │ ├── alipay.rb │ │ ├── cookies_serializer.rb │ │ ├── session_store.rb │ │ ├── mime_types.rb │ │ └── filter_parameter_logging.rb │ ├── boot.rb │ ├── environment.rb │ └── sidekiq.yml ├── lib │ ├── assets │ │ ├── .keep │ │ └── stylesheets │ │ │ └── a.scss │ ├── tasks │ │ ├── .keep │ │ └── db.rake │ └── test.rb ├── test │ ├── models │ │ ├── .keep │ │ ├── product_test.rb │ │ └── variant_test.rb │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ ├── .keep │ │ └── variants.yml │ ├── helpers │ │ └── .keep │ ├── integration │ │ └── .keep │ └── mailers │ │ └── .keep ├── .ruby-gemset ├── public │ ├── favicon.ico │ └── robots.txt ├── .ruby-version ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ ├── .keep │ │ └── b.scss ├── .rspec ├── db │ ├── redis │ │ └── dump.rdb │ └── migrate │ │ ├── 20150627170639_add_role_to_users.rb │ │ ├── 20150430090443_add_color_to_variants.rb │ │ ├── 20150612052304_add_orders_count_to_users.rb │ │ └── 20150602124315_add_columns_to_products.rb ├── bin │ ├── rake │ ├── bundle │ └── rails ├── spec │ ├── models │ │ ├── user_spec.rb │ │ ├── address_spec.rb │ │ ├── catalog_spec.rb │ │ ├── cart_item_spec.rb │ │ ├── line_item_spec.rb │ │ └── order_spec.rb │ ├── factories │ │ ├── line_items.rb │ │ ├── cart_items.rb │ │ ├── catalogs.rb │ │ ├── orders.rb │ │ └── products.rb │ ├── jobs │ │ └── order_create_job_spec.rb │ └── mailers │ │ ├── order_mailer_spec.rb │ │ └── previews │ │ └── order_mailer_preview.rb ├── config.ru └── Rakefile ├── chapter_1 ├── shop │ ├── log │ │ └── .keep │ ├── app │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ └── concerns │ │ │ │ └── .keep │ │ ├── assets │ │ │ └── images │ │ │ │ └── .keep │ │ ├── controllers │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ └── application_controller.rb │ │ └── helpers │ │ │ └── application_helper.rb │ ├── lib │ │ ├── assets │ │ │ └── .keep │ │ └── tasks │ │ │ ├── .keep │ │ │ └── say.rake │ ├── public │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test │ │ ├── helpers │ │ │ └── .keep │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ └── .keep │ │ ├── controllers │ │ │ └── .keep │ │ ├── fixtures │ │ │ └── .keep │ │ └── integration │ │ │ └── .keep │ ├── vendor │ │ └── assets │ │ │ ├── javascripts │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ └── .keep │ ├── bin │ │ ├── bundle │ │ ├── rake │ │ └── rails │ ├── config │ │ ├── boot.rb │ │ ├── initializers │ │ │ ├── cookies_serializer.rb │ │ │ ├── session_store.rb │ │ │ ├── mime_types.rb │ │ │ └── filter_parameter_logging.rb │ │ └── environment.rb │ ├── config.ru │ └── README.md ├── shop-with-bootstrap │ ├── log │ │ └── .keep │ ├── app │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ └── product.rb │ │ ├── assets │ │ │ ├── images │ │ │ │ └── .keep │ │ │ └── javascripts │ │ │ │ └── bootstrap.js.coffee │ │ ├── controllers │ │ │ └── concerns │ │ │ │ └── .keep │ │ ├── helpers │ │ │ ├── products_helper.rb │ │ │ └── application_helper.rb │ │ └── views │ │ │ └── products │ │ │ ├── show.json.jbuilder │ │ │ └── index.json.jbuilder │ ├── lib │ │ ├── assets │ │ │ └── .keep │ │ └── tasks │ │ │ └── .keep │ ├── public │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test │ │ ├── helpers │ │ │ └── .keep │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ └── product_test.rb │ │ ├── controllers │ │ │ └── .keep │ │ ├── fixtures │ │ │ └── .keep │ │ └── integration │ │ │ └── .keep │ ├── vendor │ │ └── assets │ │ │ ├── javascripts │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ └── .keep │ ├── bin │ │ ├── rake │ │ ├── bundle │ │ └── rails │ ├── config │ │ ├── boot.rb │ │ ├── initializers │ │ │ ├── cookies_serializer.rb │ │ │ ├── session_store.rb │ │ │ ├── mime_types.rb │ │ │ └── filter_parameter_logging.rb │ │ └── environment.rb │ └── config.ru └── shop-with-bootswatch │ ├── log │ └── .keep │ ├── app │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ └── product.rb │ ├── assets │ │ ├── images │ │ │ └── .keep │ │ ├── javascripts │ │ │ ├── united │ │ │ │ └── bootswatch.js │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ ├── bootstrap.js.coffee │ │ │ ├── simplex.js │ │ │ ├── united.js │ │ │ └── cerulean.js │ │ └── stylesheets │ │ │ ├── united.css │ │ │ ├── simplex.css │ │ │ ├── cerulean.css │ │ │ └── application.css.scss │ ├── controllers │ │ └── concerns │ │ │ └── .keep │ ├── helpers │ │ ├── products_helper.rb │ │ └── application_helper.rb │ └── views │ │ └── products │ │ ├── show.json.jbuilder │ │ └── index.json.jbuilder │ ├── lib │ ├── assets │ │ └── .keep │ └── tasks │ │ └── .keep │ ├── test │ ├── models │ │ ├── .keep │ │ └── product_test.rb │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ └── .keep │ ├── helpers │ │ └── .keep │ ├── integration │ │ └── .keep │ └── mailers │ │ └── .keep │ ├── public │ ├── favicon.ico │ └── robots.txt │ ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ └── .keep │ ├── bin │ ├── rake │ ├── bundle │ └── rails │ ├── config │ ├── boot.rb │ ├── initializers │ │ ├── cookies_serializer.rb │ │ ├── session_store.rb │ │ ├── mime_types.rb │ │ └── filter_parameter_logging.rb │ └── environment.rb │ └── config.ru ├── chapter_2 └── shop │ ├── log │ └── .keep │ ├── app │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ ├── product.rb │ │ └── variant.rb │ ├── assets │ │ ├── images │ │ │ └── .keep │ │ ├── javascripts │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ ├── united │ │ │ │ └── bootswatch.js │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ ├── bootstrap.js.coffee │ │ │ ├── united.js │ │ │ ├── simplex.js │ │ │ ├── cerulean.js │ │ │ ├── products.coffee │ │ │ └── variants.coffee │ │ └── stylesheets │ │ │ ├── simplex │ │ │ └── custom.less │ │ │ ├── united.css │ │ │ ├── simplex.css │ │ │ └── cerulean.css │ ├── controllers │ │ ├── concerns │ │ │ └── .keep │ │ ├── home_controller.rb │ │ └── application_controller.rb │ ├── helpers │ │ ├── home_helper.rb │ │ ├── products_helper.rb │ │ ├── variants_helper.rb │ │ └── application_helper.rb │ └── views │ │ ├── variants │ │ ├── show.json.jbuilder │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ └── index.json.jbuilder │ │ ├── products │ │ ├── show.json.jbuilder │ │ └── index.json.jbuilder │ │ └── home │ │ └── index.html.erb │ ├── lib │ ├── assets │ │ └── .keep │ ├── tasks │ │ └── .keep │ └── test.rb │ ├── public │ ├── favicon.ico │ └── robots.txt │ ├── test │ ├── helpers │ │ └── .keep │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── product_test.rb │ │ └── variant_test.rb │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ └── .keep │ └── integration │ │ └── .keep │ ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ └── .keep │ ├── .rspec │ ├── bin │ ├── rake │ ├── bundle │ └── rails │ ├── config │ ├── boot.rb │ ├── initializers │ │ ├── cookies_serializer.rb │ │ ├── session_store.rb │ │ ├── mime_types.rb │ │ └── filter_parameter_logging.rb │ └── environment.rb │ ├── spec │ ├── models │ │ └── product_spec.rb │ └── views │ │ └── home │ │ └── index.html.erb_spec.rb │ ├── config.ru │ └── README.md ├── chapter_3 ├── shop │ ├── _footer.erb │ ├── log │ │ └── .keep │ ├── app │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ ├── variant.rb │ │ │ └── product.rb │ │ ├── assets │ │ │ ├── images │ │ │ │ ├── .keep │ │ │ │ ├── logo.png │ │ │ │ └── favicon.ico │ │ │ ├── javascripts │ │ │ │ ├── simplex │ │ │ │ │ └── bootswatch.js │ │ │ │ ├── united │ │ │ │ │ └── bootswatch.js │ │ │ │ ├── cerulean │ │ │ │ │ └── bootswatch.js │ │ │ │ ├── bootstrap.js.coffee │ │ │ │ ├── united.js │ │ │ │ ├── simplex.js │ │ │ │ ├── cerulean.js │ │ │ │ └── variants.coffee │ │ │ └── stylesheets │ │ │ │ ├── simplex │ │ │ │ └── custom.less │ │ │ │ ├── united.css │ │ │ │ ├── simplex.css │ │ │ │ └── cerulean.css │ │ ├── controllers │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ ├── admin │ │ │ │ ├── base_controller.rb │ │ │ │ └── home_controller.rb │ │ │ ├── admins_controller.rb │ │ │ └── home_controller.rb │ │ ├── views │ │ │ ├── admin │ │ │ │ └── home │ │ │ │ │ └── index.html.erb │ │ │ ├── application │ │ │ │ ├── _flash.html.erb │ │ │ │ └── _footer.html.haml │ │ │ ├── products │ │ │ │ ├── destroy.js.erb │ │ │ │ ├── show.json.jbuilder │ │ │ │ ├── update.json.jbuilder │ │ │ │ ├── index.json.jbuilder │ │ │ │ └── edit.html.erb │ │ │ ├── variants │ │ │ │ ├── show.json.jbuilder │ │ │ │ ├── new.html.erb │ │ │ │ ├── edit.html.erb │ │ │ │ └── index.json.jbuilder │ │ │ ├── home │ │ │ │ └── index.html.erb │ │ │ └── devise │ │ │ │ └── mailer │ │ │ │ └── confirmation_instructions.html.erb │ │ └── helpers │ │ │ ├── home_helper.rb │ │ │ ├── products_helper.rb │ │ │ ├── variants_helper.rb │ │ │ └── application_helper.rb │ ├── lib │ │ ├── assets │ │ │ └── .keep │ │ ├── tasks │ │ │ ├── .keep │ │ │ └── db.rake │ │ └── test.rb │ ├── public │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test │ │ ├── helpers │ │ │ └── .keep │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ ├── product_test.rb │ │ │ └── variant_test.rb │ │ ├── controllers │ │ │ └── .keep │ │ ├── fixtures │ │ │ └── .keep │ │ └── integration │ │ │ └── .keep │ ├── vendor │ │ └── assets │ │ │ ├── javascripts │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ └── .keep │ ├── .rspec │ ├── bin │ │ ├── rake │ │ ├── bundle │ │ └── rails │ ├── config │ │ ├── boot.rb │ │ ├── initializers │ │ │ ├── cookies_serializer.rb │ │ │ ├── session_store.rb │ │ │ ├── mime_types.rb │ │ │ └── filter_parameter_logging.rb │ │ └── environment.rb │ ├── spec │ │ ├── models │ │ │ ├── user_spec.rb │ │ │ └── product_spec.rb │ │ └── views │ │ │ └── home │ │ │ └── index.html.erb_spec.rb │ ├── config.ru │ └── _footer.html.haml ├── shop3.1 │ ├── log │ │ └── .keep │ ├── lib │ │ ├── tasks │ │ │ └── .keep │ │ └── assets │ │ │ └── .keep │ ├── app │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ └── product.rb │ │ ├── assets │ │ │ ├── images │ │ │ │ ├── .keep │ │ │ │ └── logo.png │ │ │ ├── stylesheets │ │ │ │ ├── overrides.css.scss │ │ │ │ ├── united.css │ │ │ │ ├── simplex.css │ │ │ │ └── cerulean.css │ │ │ └── javascripts │ │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ │ ├── united │ │ │ │ └── bootswatch.js │ │ │ │ ├── united.js │ │ │ │ ├── simplex.js │ │ │ │ ├── cerulean.js │ │ │ │ └── products.coffee │ │ ├── controllers │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ └── application_controller.rb │ │ ├── views │ │ │ ├── layouts │ │ │ │ └── another_layout.html.erb │ │ │ └── products │ │ │ │ ├── show.json.jbuilder │ │ │ │ └── index.json.jbuilder │ │ └── helpers │ │ │ └── application_helper.rb │ ├── public │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test │ │ ├── fixtures │ │ │ └── .keep │ │ ├── helpers │ │ │ └── .keep │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ └── product_test.rb │ │ ├── controllers │ │ │ └── .keep │ │ └── integration │ │ │ └── .keep │ ├── vendor │ │ └── assets │ │ │ ├── javascripts │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ └── .keep │ ├── bin │ │ ├── bundle │ │ ├── rake │ │ └── rails │ ├── config │ │ ├── boot.rb │ │ ├── initializers │ │ │ ├── cookies_serializer.rb │ │ │ ├── session_store.rb │ │ │ ├── mime_types.rb │ │ │ └── filter_parameter_logging.rb │ │ └── environment.rb │ └── config.ru ├── shop3.2 │ ├── log │ │ └── .keep │ ├── lib │ │ ├── tasks │ │ │ └── .keep │ │ └── assets │ │ │ └── .keep │ ├── app │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ └── product.rb │ │ ├── assets │ │ │ ├── images │ │ │ │ ├── .keep │ │ │ │ └── logo.png │ │ │ ├── javascripts │ │ │ │ ├── cerulean │ │ │ │ │ └── bootswatch.js │ │ │ │ ├── simplex │ │ │ │ │ └── bootswatch.js │ │ │ │ ├── united │ │ │ │ │ └── bootswatch.js │ │ │ │ ├── united.js │ │ │ │ ├── simplex.js │ │ │ │ ├── cerulean.js │ │ │ │ └── products.coffee │ │ │ └── stylesheets │ │ │ │ ├── united.css │ │ │ │ ├── simplex.css │ │ │ │ ├── cerulean.css │ │ │ │ └── overrides.css.scss │ │ ├── controllers │ │ │ └── concerns │ │ │ │ └── .keep │ │ ├── views │ │ │ ├── products │ │ │ │ ├── show.json.jbuilder │ │ │ │ └── index.json.jbuilder │ │ │ └── users │ │ │ │ └── sessions │ │ │ │ └── _links.html.erb │ │ └── helpers │ │ │ └── application_helper.rb │ ├── public │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test │ │ ├── fixtures │ │ │ └── .keep │ │ ├── helpers │ │ │ └── .keep │ │ ├── mailers │ │ │ └── .keep │ │ ├── models │ │ │ ├── .keep │ │ │ ├── user_test.rb │ │ │ └── product_test.rb │ │ ├── controllers │ │ │ └── .keep │ │ └── integration │ │ │ └── .keep │ ├── vendor │ │ └── assets │ │ │ ├── javascripts │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ └── .keep │ ├── bin │ │ ├── bundle │ │ ├── rake │ │ └── rails │ ├── config │ │ ├── boot.rb │ │ ├── initializers │ │ │ ├── cookies_serializer.rb │ │ │ ├── session_store.rb │ │ │ ├── mime_types.rb │ │ │ └── filter_parameter_logging.rb │ │ └── environment.rb │ └── config.ru └── shop3.3 │ ├── log │ └── .keep │ ├── lib │ ├── tasks │ │ └── .keep │ └── assets │ │ └── .keep │ ├── app │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ └── product.rb │ ├── assets │ │ ├── images │ │ │ ├── .keep │ │ │ └── logo.png │ │ ├── javascripts │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ ├── united │ │ │ │ └── bootswatch.js │ │ │ ├── united.js │ │ │ ├── simplex.js │ │ │ └── cerulean.js │ │ └── stylesheets │ │ │ ├── united.css │ │ │ ├── simplex.css │ │ │ └── cerulean.css │ ├── controllers │ │ └── concerns │ │ │ └── .keep │ ├── views │ │ ├── products │ │ │ ├── destroy.js.erb │ │ │ ├── show.json.jbuilder │ │ │ ├── create.js.erb │ │ │ ├── index.json.jbuilder │ │ │ └── update.json.jbuilder │ │ └── users │ │ │ ├── mailer │ │ │ ├── _mail_footer.html.erb │ │ │ └── confirmation_instructions.html.erb │ │ │ └── sessions │ │ │ └── _links.html.erb │ └── helpers │ │ └── application_helper.rb │ ├── public │ ├── favicon.ico │ └── robots.txt │ ├── test │ ├── fixtures │ │ └── .keep │ ├── helpers │ │ └── .keep │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── user_test.rb │ │ └── product_test.rb │ ├── controllers │ │ └── .keep │ └── integration │ │ └── .keep │ ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ └── .keep │ ├── bin │ ├── bundle │ ├── rake │ └── rails │ ├── config │ ├── boot.rb │ ├── initializers │ │ ├── cookies_serializer.rb │ │ ├── session_store.rb │ │ ├── mime_types.rb │ │ └── filter_parameter_logging.rb │ └── environment.rb │ └── config.ru ├── chapter_4 └── shop │ ├── log │ └── .keep │ ├── app │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ ├── address.rb │ │ ├── line_item.rb │ │ └── catalog.rb │ ├── assets │ │ ├── images │ │ │ ├── .keep │ │ │ ├── logo.png │ │ │ └── favicon.ico │ │ ├── javascripts │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ ├── bootstrap.js.coffee │ │ │ ├── simplex.js │ │ │ └── cerulean.js │ │ └── stylesheets │ │ │ ├── simplex │ │ │ └── custom.less │ │ │ ├── simplex.css │ │ │ └── cerulean.css │ ├── controllers │ │ ├── concerns │ │ │ └── .keep │ │ ├── admin │ │ │ ├── base_controller.rb │ │ │ └── home_controller.rb │ │ └── admins_controller.rb │ ├── views │ │ ├── admin │ │ │ └── home │ │ │ │ └── index.html.erb │ │ ├── application │ │ │ ├── _flash.html.erb │ │ │ └── _footer.html.haml │ │ ├── products │ │ │ ├── destroy.js.erb │ │ │ ├── show.json.jbuilder │ │ │ ├── update.json.jbuilder │ │ │ ├── index.json.jbuilder │ │ │ └── edit.html.erb │ │ ├── variants │ │ │ ├── edit.html.erb │ │ │ ├── show.json.jbuilder │ │ │ ├── index.json.jbuilder │ │ │ └── new.html.erb │ │ ├── home │ │ │ └── index.html.erb │ │ └── devise │ │ │ └── mailer │ │ │ └── confirmation_instructions.html.erb │ └── helpers │ │ ├── home_helper.rb │ │ ├── products_helper.rb │ │ ├── variants_helper.rb │ │ └── application_helper.rb │ ├── lib │ ├── assets │ │ └── .keep │ ├── tasks │ │ ├── .keep │ │ └── db.rake │ └── test.rb │ ├── public │ ├── favicon.ico │ └── robots.txt │ ├── test │ ├── helpers │ │ └── .keep │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── product_test.rb │ │ └── variant_test.rb │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ └── .keep │ └── integration │ │ └── .keep │ ├── .ruby-gemset │ ├── .ruby-version │ ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ └── .keep │ ├── .rspec │ ├── config │ ├── locales │ │ ├── zh-CN.yml │ │ └── models │ │ │ ├── order │ │ │ └── zh-CN.yml │ │ │ └── variant │ │ │ └── zh-CN.yml │ ├── boot.rb │ ├── initializers │ │ ├── cookies_serializer.rb │ │ ├── session_store.rb │ │ ├── mime_types.rb │ │ └── filter_parameter_logging.rb │ └── environment.rb │ ├── bin │ ├── rake │ ├── bundle │ └── rails │ ├── spec │ ├── models │ │ ├── order_spec.rb │ │ ├── user_spec.rb │ │ ├── address_spec.rb │ │ ├── line_item_spec.rb │ │ └── catalog_spec.rb │ └── factories │ │ ├── line_items.rb │ │ ├── catalogs.rb │ │ ├── orders.rb │ │ └── products.rb │ ├── config.ru │ └── db │ └── migrate │ ├── 20150430090443_add_color_to_variants.rb │ ├── 20150612052304_add_orders_count_to_users.rb │ ├── 20150719071616_add_on_hand_to_variants.rb │ └── 20150602124315_add_columns_to_products.rb ├── chapter_5 └── shop │ ├── log │ └── .keep │ ├── app │ ├── mailers │ │ ├── .keep │ │ ├── application_mailer.rb │ │ └── order_mailer.rb │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ ├── address.rb │ │ ├── cart_item.rb │ │ ├── line_item.rb │ │ ├── product.rb │ │ └── catalog.rb │ ├── assets │ │ ├── images │ │ │ ├── .keep │ │ │ ├── logo.png │ │ │ └── favicon.ico │ │ ├── javascripts │ │ │ ├── simplex │ │ │ │ └── bootswatch.js │ │ │ ├── cerulean │ │ │ │ └── bootswatch.js │ │ │ ├── bootstrap.js.coffee │ │ │ ├── simplex.js │ │ │ └── cerulean.js │ │ └── stylesheets │ │ │ ├── simplex │ │ │ └── custom.less │ │ │ ├── simplex.css │ │ │ └── cerulean.css │ ├── controllers │ │ ├── concerns │ │ │ └── .keep │ │ ├── admin │ │ │ ├── base_controller.rb │ │ │ └── home_controller.rb │ │ └── admins_controller.rb │ ├── views │ │ ├── admin │ │ │ └── home │ │ │ │ └── index.html.erb │ │ ├── application │ │ │ ├── _flash.html.erb │ │ │ └── _footer.html.haml │ │ ├── products │ │ │ ├── destroy.js.erb │ │ │ ├── show.json.jbuilder │ │ │ ├── update.json.jbuilder │ │ │ ├── index.json.jbuilder │ │ │ └── edit.html.erb │ │ ├── orders │ │ │ ├── show.json.jbuilder │ │ │ ├── new.html.erb │ │ │ ├── index.json.jbuilder │ │ │ └── edit.html.erb │ │ ├── order_mailer │ │ │ ├── confirm_email.text.erb │ │ │ └── confirm_email.html.erb │ │ ├── variants │ │ │ ├── show.json.jbuilder │ │ │ ├── new.html.erb │ │ │ ├── edit.html.erb │ │ │ └── index.json.jbuilder │ │ ├── layouts │ │ │ └── mailer.text.erb │ │ ├── home │ │ │ └── index.html.erb │ │ └── devise │ │ │ └── mailer │ │ │ └── confirmation_instructions.html.erb │ ├── helpers │ │ ├── home_helper.rb │ │ ├── orders_helper.rb │ │ ├── products_helper.rb │ │ ├── variants_helper.rb │ │ └── application_helper.rb │ └── jobs │ │ └── order_create_job.rb │ ├── config │ ├── deploy.rb │ ├── puma.rb │ ├── locales │ │ ├── zh-CN.yml │ │ └── models │ │ │ └── order │ │ │ └── zh-CN.yml │ ├── initializers │ │ ├── alipay.rb │ │ ├── cookies_serializer.rb │ │ ├── session_store.rb │ │ ├── mime_types.rb │ │ └── filter_parameter_logging.rb │ ├── boot.rb │ └── environment.rb │ ├── lib │ ├── assets │ │ ├── .keep │ │ └── stylesheets │ │ │ └── a.scss │ ├── tasks │ │ ├── .keep │ │ └── db.rake │ └── test.rb │ ├── public │ ├── favicon.ico │ └── robots.txt │ ├── test │ ├── helpers │ │ └── .keep │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── product_test.rb │ │ └── variant_test.rb │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ └── .keep │ └── integration │ │ └── .keep │ ├── .ruby-gemset │ ├── .ruby-version │ ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ ├── .keep │ │ └── b.scss │ ├── .rspec │ ├── db │ ├── redis │ │ └── dump.rdb │ └── migrate │ │ ├── 20150627170639_add_role_to_users.rb │ │ ├── 20150430090443_add_color_to_variants.rb │ │ ├── 20150612052304_add_orders_count_to_users.rb │ │ └── 20150602124315_add_columns_to_products.rb │ ├── bin │ ├── rake │ ├── bundle │ └── rails │ ├── spec │ ├── models │ │ ├── user_spec.rb │ │ ├── address_spec.rb │ │ ├── catalog_spec.rb │ │ ├── cart_item_spec.rb │ │ ├── line_item_spec.rb │ │ └── order_spec.rb │ ├── factories │ │ ├── line_items.rb │ │ ├── cart_items.rb │ │ ├── catalogs.rb │ │ ├── orders.rb │ │ └── products.rb │ ├── mailers │ │ ├── order_mailer_spec.rb │ │ └── previews │ │ │ └── order_mailer_preview.rb │ └── jobs │ │ └── order_create_job_spec.rb │ └── config.ru └── chapter_6 └── shop ├── log └── .keep ├── app ├── mailers │ ├── .keep │ ├── application_mailer.rb │ └── order_mailer.rb ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── address.rb │ ├── line_item.rb │ └── catalog.rb ├── assets │ ├── images │ │ ├── .keep │ │ ├── logo.png │ │ └── favicon.ico │ ├── javascripts │ │ ├── simplex │ │ │ └── bootswatch.js │ │ ├── cerulean │ │ │ └── bootswatch.js │ │ ├── bootstrap.js.coffee │ │ ├── simplex.js │ │ └── cerulean.js │ └── stylesheets │ │ ├── simplex │ │ └── custom.less │ │ ├── simplex.css │ │ └── cerulean.css ├── controllers │ ├── concerns │ │ └── .keep │ ├── admin │ │ ├── base_controller.rb │ │ └── home_controller.rb │ └── admins_controller.rb ├── views │ ├── admin │ │ └── home │ │ │ └── index.html.erb │ ├── application │ │ ├── _flash.html.erb │ │ └── _footer.html.haml │ ├── products │ │ ├── destroy.js.erb │ │ ├── show.json.jbuilder │ │ ├── update.json.jbuilder │ │ ├── index.json.jbuilder │ │ └── edit.html.erb │ ├── order_mailer │ │ ├── confirm_email.text.erb │ │ └── confirm_email.html.erb │ ├── variants │ │ ├── show.json.jbuilder │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ └── index.json.jbuilder │ ├── layouts │ │ └── mailer.text.erb │ ├── home │ │ └── index.html.erb │ └── devise │ │ └── mailer │ │ └── confirmation_instructions.html.erb ├── helpers │ ├── home_helper.rb │ ├── products_helper.rb │ ├── variants_helper.rb │ └── application_helper.rb └── jobs │ └── order_create_job.rb ├── config ├── deploy.rb ├── puma.rb ├── locales │ ├── zh-CN.yml │ └── models │ │ └── order │ │ └── zh-CN.yml ├── boot.rb ├── initializers │ ├── cookies_serializer.rb │ ├── session_store.rb │ ├── mime_types.rb │ └── filter_parameter_logging.rb └── environment.rb ├── lib ├── assets │ ├── .keep │ └── stylesheets │ │ └── a.scss ├── tasks │ ├── .keep │ └── db.rake └── test.rb ├── public ├── favicon.ico └── robots.txt ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── product_test.rb │ └── variant_test.rb ├── controllers │ └── .keep ├── fixtures │ └── .keep └── integration │ └── .keep ├── .ruby-gemset ├── .ruby-version ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ ├── .keep │ └── b.scss ├── .rspec ├── db ├── redis │ └── dump.rdb └── migrate │ ├── 20150430090443_add_color_to_variants.rb │ ├── 20150612052304_add_orders_count_to_users.rb │ └── 20150602124315_add_columns_to_products.rb ├── bin ├── rake ├── bundle └── rails ├── spec ├── models │ ├── order_spec.rb │ ├── user_spec.rb │ ├── address_spec.rb │ ├── catalog_spec.rb │ └── line_item_spec.rb ├── factories │ ├── line_items.rb │ ├── catalogs.rb │ ├── orders.rb │ └── products.rb ├── mailers │ ├── order_mailer_spec.rb │ └── previews │ │ └── order_mailer_preview.rb └── jobs │ └── order_create_job_spec.rb └── config.ru /final/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/config/deploy.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/config/puma.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/_footer.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/.ruby-gemset: -------------------------------------------------------------------------------- 1 | shop 2 | -------------------------------------------------------------------------------- /final/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/config/deploy.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/config/puma.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/config/deploy.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/config/puma.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | -------------------------------------------------------------------------------- /final/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/.ruby-gemset: -------------------------------------------------------------------------------- 1 | shop 2 | -------------------------------------------------------------------------------- /chapter_4/shop/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/.ruby-gemset: -------------------------------------------------------------------------------- 1 | shop 2 | -------------------------------------------------------------------------------- /chapter_5/shop/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/.ruby-gemset: -------------------------------------------------------------------------------- 1 | shop 2 | -------------------------------------------------------------------------------- /chapter_6/shop/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/lib/test.rb: -------------------------------------------------------------------------------- 1 | p Product.all 2 | -------------------------------------------------------------------------------- /final/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/app/views/admin/home/index.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/lib/test.rb: -------------------------------------------------------------------------------- 1 | p Product.all 2 | -------------------------------------------------------------------------------- /chapter_2/shop/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/lib/test.rb: -------------------------------------------------------------------------------- 1 | p Product.all 2 | -------------------------------------------------------------------------------- /chapter_3/shop/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/lib/test.rb: -------------------------------------------------------------------------------- 1 | p Product.all 2 | -------------------------------------------------------------------------------- /chapter_4/shop/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/lib/test.rb: -------------------------------------------------------------------------------- 1 | p Product.all 2 | -------------------------------------------------------------------------------- /chapter_5/shop/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/lib/test.rb: -------------------------------------------------------------------------------- 1 | p Product.all 2 | -------------------------------------------------------------------------------- /chapter_6/shop/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/admin/home/index.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/admin/home/index.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/admin/home/index.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/admin/home/index.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /final/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chapter_2/shop/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /chapter_3/shop/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /chapter_4/shop/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /chapter_5/shop/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /chapter_6/shop/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /final/app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/config/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | hello: "你好" 3 | -------------------------------------------------------------------------------- /chapter_4/shop/config/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | hello: "你好" 3 | -------------------------------------------------------------------------------- /chapter_5/shop/config/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | hello: "你好" 3 | -------------------------------------------------------------------------------- /chapter_6/shop/config/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | hello: "你好" 3 | -------------------------------------------------------------------------------- /final/app/helpers/orders_helper.rb: -------------------------------------------------------------------------------- 1 | module OrdersHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_2/shop/app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_4/shop/app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_5/shop/app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_6/shop/app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/app/helpers/variants_helper.rb: -------------------------------------------------------------------------------- 1 | module VariantsHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/app/views/application/_flash.html.erb: -------------------------------------------------------------------------------- 1 | <%= bootstrap_flash %> 2 | -------------------------------------------------------------------------------- /chapter_5/shop/app/helpers/orders_helper.rb: -------------------------------------------------------------------------------- 1 | module OrdersHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/config/initializers/alipay.rb: -------------------------------------------------------------------------------- 1 | Alipay.pid = '' 2 | Alipay.key = '' 3 | -------------------------------------------------------------------------------- /chapter_2/shop/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_2/shop/app/helpers/variants_helper.rb: -------------------------------------------------------------------------------- 1 | module VariantsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_2/shop/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_2/shop/app/models/variant.rb: -------------------------------------------------------------------------------- 1 | class Variant < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/helpers/variants_helper.rb: -------------------------------------------------------------------------------- 1 | module VariantsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/models/variant.rb: -------------------------------------------------------------------------------- 1 | class Variant < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/application/_flash.html.erb: -------------------------------------------------------------------------------- 1 | <%= bootstrap_flash %> 2 | -------------------------------------------------------------------------------- /chapter_4/shop/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_4/shop/app/helpers/variants_helper.rb: -------------------------------------------------------------------------------- 1 | module VariantsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/application/_flash.html.erb: -------------------------------------------------------------------------------- 1 | <%= bootstrap_flash %> 2 | -------------------------------------------------------------------------------- /chapter_5/shop/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_5/shop/app/helpers/variants_helper.rb: -------------------------------------------------------------------------------- 1 | module VariantsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/application/_flash.html.erb: -------------------------------------------------------------------------------- 1 | <%= bootstrap_flash %> 2 | -------------------------------------------------------------------------------- /chapter_6/shop/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_6/shop/app/helpers/variants_helper.rb: -------------------------------------------------------------------------------- 1 | module VariantsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/application/_flash.html.erb: -------------------------------------------------------------------------------- 1 | <%= bootstrap_flash %> 2 | -------------------------------------------------------------------------------- /chapter_1/shop/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_2/shop/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_4/shop/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_5/shop/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_5/shop/config/initializers/alipay.rb: -------------------------------------------------------------------------------- 1 | Alipay.pid = '' 2 | Alipay.key = '' 3 | -------------------------------------------------------------------------------- /chapter_6/shop/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /final/app/views/products/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#product_<%= @product.id %>').fadeOut(); 2 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/helpers/products_helper.rb: -------------------------------------------------------------------------------- 1 | module ProductsHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/products/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#product_<%= @product.id %>').fadeOut(); 2 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/products/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#product_<%= @product.id %>').fadeOut(); 2 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/products/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#product_<%= @product.id %>').fadeOut(); 2 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/products/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#product_<%= @product.id %>').fadeOut(); 2 | -------------------------------------------------------------------------------- /final/app/views/orders/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @order, :id, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /final/lib/assets/stylesheets/a.scss: -------------------------------------------------------------------------------- 1 | // From lib/assets 2 | .body { 3 | color: #aaa; 4 | } 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/stylesheets/overrides.css.scss: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 60px; 3 | } 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/products/destroy.js.erb: -------------------------------------------------------------------------------- 1 | $('#product_<%= @product.id %>').fadeOut(); 2 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/variants/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Variant

2 | 3 | <%= render 'form' %> 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/orders/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @order, :id, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_5/shop/lib/assets/stylesheets/a.scss: -------------------------------------------------------------------------------- 1 | // From lib/assets 2 | .body { 3 | color: #aaa; 4 | } 5 | -------------------------------------------------------------------------------- /chapter_6/shop/lib/assets/stylesheets/a.scss: -------------------------------------------------------------------------------- 1 | // From lib/assets 2 | .body { 3 | color: #aaa; 4 | } 5 | -------------------------------------------------------------------------------- /final/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /final/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /final/vendor/assets/stylesheets/b.scss: -------------------------------------------------------------------------------- 1 | // From vendor/assets 2 | .body { 3 | color: #bbb; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/united/bootswatch.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/united/bootswatch.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/views/layouts/another_layout.html.erb: -------------------------------------------------------------------------------- 1 |

Hi, 这是另一个布局

2 |
3 | <%= yield %> 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /final/app/assets/stylesheets/simplex/custom.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: @navbar-default-bg; 3 | } 4 | -------------------------------------------------------------------------------- /final/app/views/order_mailer/confirm_email.text.erb: -------------------------------------------------------------------------------- 1 | 你好, <%= @user.email %>,您的订单 <%= @order.number %> 已经确认。 2 | -------------------------------------------------------------------------------- /final/db/redis/dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/final/db/redis/dump.rdb -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/united/bootswatch.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/united/bootswatch.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/javascripts/united/bootswatch.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_5/shop/vendor/assets/stylesheets/b.scss: -------------------------------------------------------------------------------- 1 | // From vendor/assets 2 | .body { 3 | color: #bbb; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_6/shop/vendor/assets/stylesheets/b.scss: -------------------------------------------------------------------------------- 1 | // From vendor/assets 2 | .body { 3 | color: #bbb; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/stylesheets/simplex/custom.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: @navbar-default-bg; 3 | } 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/stylesheets/simplex/custom.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: @navbar-default-bg; 3 | } 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/stylesheets/simplex/custom.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: @navbar-default-bg; 3 | } 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/stylesheets/simplex/custom.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: @navbar-default-bg; 3 | } 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/order_mailer/confirm_email.text.erb: -------------------------------------------------------------------------------- 1 | 你好, <%= @user.email %>,您的订单 <%= @order.number %> 已经确认。 2 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/stylesheets/simplex/custom.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: @navbar-default-bg; 3 | } 4 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/order_mailer/confirm_email.text.erb: -------------------------------------------------------------------------------- 1 | 你好, <%= @user.email %>,您的订单 <%= @order.number %> 已经确认。 2 | -------------------------------------------------------------------------------- /final/app/models/address.rb: -------------------------------------------------------------------------------- 1 | class Address < ActiveRecord::Base 2 | belongs_to :user, inverse_of: :address 3 | end 4 | -------------------------------------------------------------------------------- /final/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/united/bootswatch.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/address.rb: -------------------------------------------------------------------------------- 1 | class Address < ActiveRecord::Base 2 | belongs_to :user, inverse_of: :address 3 | end 4 | -------------------------------------------------------------------------------- /chapter_5/shop/db/redis/dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_5/shop/db/redis/dump.rdb -------------------------------------------------------------------------------- /chapter_6/shop/app/models/address.rb: -------------------------------------------------------------------------------- 1 | class Address < ActiveRecord::Base 2 | belongs_to :user, inverse_of: :address 3 | end 4 | -------------------------------------------------------------------------------- /chapter_6/shop/db/redis/dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_6/shop/db/redis/dump.rdb -------------------------------------------------------------------------------- /final/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/final/app/assets/images/logo.png -------------------------------------------------------------------------------- /final/app/models/cart_item.rb: -------------------------------------------------------------------------------- 1 | class CartItem < ActiveRecord::Base 2 | belongs_to :user 3 | belongs_to :variant 4 | end 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/cerulean/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/simplex/bootswatch.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | // bootswatch.js 4 | -------------------------------------------------------------------------------- /chapter_2/shop/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_3/shop/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/users/mailer/_mail_footer.html.erb: -------------------------------------------------------------------------------- 1 | ------------------------ 2 |

<%= Time.now.to_s(:db) %> 发

3 | -------------------------------------------------------------------------------- /chapter_4/shop/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_5/shop/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_6/shop/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /final/app/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/final/app/assets/images/favicon.ico -------------------------------------------------------------------------------- /final/app/views/orders/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Order

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', orders_path %> 6 | -------------------------------------------------------------------------------- /final/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /final/app/views/variants/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @variant, :id, :product_id, :price, :size, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/variants/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @variant, :id, :product_id, :price, :size, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/variants/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @variant, :id, :product_id, :price, :size, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/variants/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @variant, :id, :product_id, :price, :size, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/cart_item.rb: -------------------------------------------------------------------------------- 1 | class CartItem < ActiveRecord::Base 2 | belongs_to :user 3 | belongs_to :variant 4 | end 5 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/variants/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @variant, :id, :product_id, :price, :size, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/variants/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @variant, :id, :product_id, :price, :size, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /final/app/views/variants/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', variants_path %> 6 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | validates :description, length: { minimum: 5 } 3 | end 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/orders/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Order

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', orders_path %> 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /final/app/controllers/admin/base_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::BaseController < ApplicationController 2 | 3 | layout "admin" 4 | 5 | end 6 | -------------------------------------------------------------------------------- /final/app/views/order_mailer/confirm_email.html.erb: -------------------------------------------------------------------------------- 1 |

你好, <%= @user.email %>

2 |

3 | 您的订单 <%= @order.number %> 已经确认。 4 |

5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/variants/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', variants_path %> 6 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_3/shop/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_3/shop/app/views/variants/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', variants_path %> 6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_4/shop/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_5/shop/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_5/shop/app/views/variants/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', variants_path %> 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_6/shop/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_6/shop/app/views/variants/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', variants_path %> 6 | -------------------------------------------------------------------------------- /final/app/controllers/admin/home_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::HomeController < Admin::BaseController 2 | 3 | def index 4 | 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_3/shop/app/assets/images/favicon.ico -------------------------------------------------------------------------------- /chapter_3/shop/app/controllers/admin/base_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::BaseController < ApplicationController 2 | 3 | layout "admin" 4 | 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_3/shop3.1/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :description, :price, :price, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_3/shop3.2/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :description, :price, :price, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_3/shop3.3/app/assets/images/logo.png -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :description, :price, :price, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_4/shop/app/assets/images/favicon.ico -------------------------------------------------------------------------------- /chapter_4/shop/app/controllers/admin/base_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::BaseController < ApplicationController 2 | 3 | layout "admin" 4 | 5 | end 6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/models/address.rb: -------------------------------------------------------------------------------- 1 | class Address < ActiveRecord::Base 2 | belongs_to :user, inverse_of: :address, :dependent: :destroy 3 | end 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_5/shop/app/assets/images/favicon.ico -------------------------------------------------------------------------------- /chapter_5/shop/app/controllers/admin/base_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::BaseController < ApplicationController 2 | 3 | layout "admin" 4 | 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/order_mailer/confirm_email.html.erb: -------------------------------------------------------------------------------- 1 |

你好, <%= @user.email %>

2 |

3 | 您的订单 <%= @order.number %> 已经确认。 4 |

5 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liwei78/rails-practice-code/HEAD/chapter_6/shop/app/assets/images/favicon.ico -------------------------------------------------------------------------------- /chapter_6/shop/app/controllers/admin/base_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::BaseController < ApplicationController 2 | 3 | layout "admin" 4 | 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/order_mailer/confirm_email.html.erb: -------------------------------------------------------------------------------- 1 |

你好, <%= @user.email %>

2 |

3 | 您的订单 <%= @order.number %> 已经确认。 4 |

5 | -------------------------------------------------------------------------------- /final/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | 3 | ======================================= 4 | 5 | 《Rails 实践》http://rails-practice.com 6 | -------------------------------------------------------------------------------- /final/spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, type: :model do 4 | it { should have_many(:orders) } 5 | end 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/views/products/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! @product, :id, :name, :price, :description, :created_at, :updated_at 2 | -------------------------------------------------------------------------------- /chapter_3/shop/app/controllers/admin/home_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::HomeController < Admin::BaseController 2 | 3 | def index 4 | 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_4/shop/app/controllers/admin/home_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::HomeController < Admin::BaseController 2 | 3 | def index 4 | 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_5/shop/app/controllers/admin/home_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::HomeController < Admin::BaseController 2 | 3 | def index 4 | 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_6/shop/app/controllers/admin/home_controller.rb: -------------------------------------------------------------------------------- 1 | class Admin::HomeController < Admin::BaseController 2 | 3 | def index 4 | 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /final/app/controllers/admins_controller.rb: -------------------------------------------------------------------------------- 1 | class AdminsController < ApplicationController 2 | layout "admin" 3 | 4 | def show 5 | 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /final/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "post4mail@163.com" 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /final/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_1/shop/lib/tasks/say.rake: -------------------------------------------------------------------------------- 1 | namespace :say do 2 | desc "It's a test rake." 3 | task :hi => :environment do 4 | puts "Hi, Rails" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_4/shop/app/models/line_item.rb: -------------------------------------------------------------------------------- 1 | class LineItem < ActiveRecord::Base 2 | belongs_to :order 3 | belongs_to :variant 4 | belongs_to :user 5 | end 6 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/models/order_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Order, type: :model do 4 | it { should belong_to(:user) } 5 | end 6 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, type: :model do 4 | it { should have_many(:orders) } 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | 3 | ======================================= 4 | 5 | 《Rails 实践》http://rails-practice.com 6 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, type: :model do 4 | it { should have_many(:orders) } 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/models/line_item.rb: -------------------------------------------------------------------------------- 1 | class LineItem < ActiveRecord::Base 2 | belongs_to :order 3 | belongs_to :variant 4 | belongs_to :user 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | 3 | ======================================= 4 | 5 | 《Rails 实践》http://rails-practice.com 6 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/models/order_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Order, type: :model do 4 | it { should belong_to(:user) } 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, type: :model do 4 | it { should have_many(:orders) } 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/factories/line_items.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :line_item do 3 | orders nil 4 | variant nil 5 | quantity 1 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_1/shop/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_2/shop/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/controllers/admins_controller.rb: -------------------------------------------------------------------------------- 1 | class AdminsController < ApplicationController 2 | layout "admin" 3 | 4 | def show 5 | 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_3/shop/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/controllers/admins_controller.rb: -------------------------------------------------------------------------------- 1 | class AdminsController < ApplicationController 2 | layout "admin" 3 | 4 | def show 5 | 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_4/shop/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/controllers/admins_controller.rb: -------------------------------------------------------------------------------- 1 | class AdminsController < ApplicationController 2 | layout "admin" 3 | 4 | def show 5 | 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_5/shop/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "post4mail@163.com" 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /chapter_5/shop/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_6/shop/app/controllers/admins_controller.rb: -------------------------------------------------------------------------------- 1 | class AdminsController < ApplicationController 2 | layout "admin" 3 | 4 | def show 5 | 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_6/shop/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "post4mail@163.com" 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /chapter_6/shop/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /final/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /final/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /final/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home#index

2 |

Find me in app/views/home/index.html.erb

3 |
4 |

<%= @name %> like <%= @like %>

5 | -------------------------------------------------------------------------------- /final/app/views/orders/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@orders) do |order| 2 | json.extract! order, :id 3 | json.url order_url(order, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /final/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /final/spec/factories/cart_items.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :cart_item do 3 | references "" 4 | references "" 5 | quantity 1 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_1/shop/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/stylesheets/united.css: -------------------------------------------------------------------------------- 1 | /* United 2 | * Bootswatch 3 | *= require_self 4 | *= require united/loader 5 | *= require united/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home#index

2 |

Find me in app/views/home/index.html.erb

3 |
4 |

<%= @name %> like <%= @like %>

5 | -------------------------------------------------------------------------------- /chapter_2/shop/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/stylesheets/united.css: -------------------------------------------------------------------------------- 1 | /* United 2 | * Bootswatch 3 | *= require_self 4 | *= require united/loader 5 | *= require united/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home#index

2 |

Find me in app/views/home/index.html.erb

3 |
4 |

<%= @name %> like <%= @like %>

5 | -------------------------------------------------------------------------------- /chapter_3/shop/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home#index

2 |

Find me in app/views/home/index.html.erb

3 |
4 |

<%= @name %> like <%= @like %>

5 | -------------------------------------------------------------------------------- /chapter_4/shop/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/factories/line_items.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :line_item do 3 | orders nil 4 | variant nil 5 | quantity 1 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home#index

2 |

Find me in app/views/home/index.html.erb

3 |
4 |

<%= @name %> like <%= @like %>

5 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/orders/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@orders) do |order| 2 | json.extract! order, :id 3 | json.url order_url(order, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_5/shop/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/factories/line_items.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :line_item do 3 | orders nil 4 | variant nil 5 | quantity 1 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Home#index

2 |

Find me in app/views/home/index.html.erb

3 |
4 |

<%= @name %> like <%= @like %>

5 | -------------------------------------------------------------------------------- /chapter_6/shop/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/factories/line_items.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :line_item do 3 | orders nil 4 | variant nil 5 | quantity 1 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /final/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /final/app/views/orders/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Order

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @order %> | 6 | <%= link_to 'Back', orders_path %> 7 | -------------------------------------------------------------------------------- /final/config/locales/models/order/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | activerecord: 3 | models: 4 | order: 订单 5 | attributes: 6 | order: 7 | number: 订单号 8 | -------------------------------------------------------------------------------- /final/spec/factories/catalogs.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :catalog do 3 | parent_catalog nil 4 | name "MyString" 5 | parent false 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/factories/cart_items.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :cart_item do 3 | references "" 4 | references "" 5 | quantity 1 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /final/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /final/spec/models/address_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Address, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/models/catalog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Catalog, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_3/shop/spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_4/shop/config/locales/models/order/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | activerecord: 3 | models: 4 | order: 订单 5 | attributes: 6 | order: 7 | number: 订单号 8 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/factories/catalogs.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :catalog do 3 | parent_catalog nil 4 | name "MyString" 5 | parent false 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/orders/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Order

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @order %> | 6 | <%= link_to 'Back', orders_path %> 7 | -------------------------------------------------------------------------------- /chapter_5/shop/config/locales/models/order/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | activerecord: 3 | models: 4 | order: 订单 5 | attributes: 6 | order: 7 | number: 订单号 8 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/factories/catalogs.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :catalog do 3 | parent_catalog nil 4 | name "MyString" 5 | parent false 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_6/shop/config/locales/models/order/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | activerecord: 3 | models: 4 | order: 订单 5 | attributes: 6 | order: 7 | number: 订单号 8 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/factories/catalogs.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :catalog do 3 | parent_catalog nil 4 | name "MyString" 5 | parent false 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /final/app/views/variants/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @variant %> | 6 | <%= link_to 'Back', variants_path %> 7 | -------------------------------------------------------------------------------- /final/db/migrate/20150627170639_add_role_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddRoleToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :role, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/models/cart_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe CartItem, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/models/line_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe LineItem, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /final/test/models/variant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class VariantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/stylesheets/united.css: -------------------------------------------------------------------------------- 1 | /* United 2 | * Bootswatch 3 | *= require_self 4 | *= require united/loader 5 | *= require united/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_2/shop/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_2/shop/spec/models/product_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Product, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_3/shop/spec/models/product_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Product, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UserTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UserTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_4/shop/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/models/address_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Address, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/models/address_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Address, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/models/catalog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Catalog, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/models/address_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Address, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/models/catalog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Catalog, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /final/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /final/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /chapter_1/shop/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/united.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require united/loader 6 | //= require united/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_2/shop/app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | @name = params[:name] 4 | @like = params[:like] 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/variants/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @variant %> | 6 | <%= link_to 'Back', variants_path %> 7 | -------------------------------------------------------------------------------- /chapter_2/shop/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_2/shop/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_2/shop/test/models/variant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class VariantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/united.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require united/loader 6 | //= require united/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | @name = params[:name] 4 | @like = params[:like] 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/variants/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @variant %> | 6 | <%= link_to 'Back', variants_path %> 7 | -------------------------------------------------------------------------------- /chapter_3/shop/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_3/shop/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_3/shop/test/models/variant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class VariantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_4/shop/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/models/line_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe LineItem, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_4/shop/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_4/shop/test/models/variant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class VariantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/variants/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @variant %> | 6 | <%= link_to 'Back', variants_path %> 7 | -------------------------------------------------------------------------------- /chapter_5/shop/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_5/shop/db/migrate/20150627170639_add_role_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddRoleToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :role, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/models/cart_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe CartItem, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/models/line_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe LineItem, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_5/shop/test/models/variant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class VariantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/variants/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Variant

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @variant %> | 6 | <%= link_to 'Back', variants_path %> 7 | -------------------------------------------------------------------------------- /chapter_6/shop/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/models/line_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe LineItem, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_6/shop/test/models/variant_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class VariantTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /final/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /final/app/views/products/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.id @product.id 2 | json.name link_to(@product.name, product_path(@product)) 3 | json.price number_to_currency(@product.price, unit: "¥") 4 | -------------------------------------------------------------------------------- /final/db/migrate/20150430090443_add_color_to_variants.rb: -------------------------------------------------------------------------------- 1 | class AddColorToVariants < ActiveRecord::Migration 2 | def change 3 | add_column :variants, :color, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/jobs/order_create_job_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe OrderCreateJob, type: :job do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/mailers/order_mailer_spec.rb: -------------------------------------------------------------------------------- 1 | require "rails_helper" 2 | 3 | RSpec.describe OrderMailer, type: :mailer do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/spec/models/order_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Order, type: :model do 4 | it { should belong_to(:user) } 5 | it { should have_many(:line_items) } 6 | end 7 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | */ 7 | -------------------------------------------------------------------------------- /chapter_1/shop/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_2/shop/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/united.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require united/loader 6 | //= require united/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/united.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require united/loader 6 | //= require united/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/javascripts/united.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require united/loader 6 | //= require united/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/products/create.js.erb: -------------------------------------------------------------------------------- 1 | $('#productsTable').prepend('<%= j render(@product) %>'); 2 | $('#newProductFormModal').modal('hide'); 3 | $('#newProductForm')[0].reset(); 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_4/shop/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_5/shop/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/mailers/order_mailer_spec.rb: -------------------------------------------------------------------------------- 1 | require "rails_helper" 2 | 3 | RSpec.describe OrderMailer, type: :mailer do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_6/shop/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/mailers/order_mailer_spec.rb: -------------------------------------------------------------------------------- 1 | require "rails_helper" 2 | 3 | RSpec.describe OrderMailer, type: :mailer do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /final/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /final/spec/mailers/previews/order_mailer_preview.rb: -------------------------------------------------------------------------------- 1 | # Preview all emails at http://localhost:3000/rails/mailers/order_mailer 2 | class OrderMailerPreview < ActionMailer::Preview 3 | 4 | end 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /chapter_1/shop/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop_session' 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/products/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.id @product.id 2 | json.name link_to(@product.name, product_path(@product)) 3 | json.price number_to_currency(@product.price, unit: "¥") 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/stylesheets/united.css: -------------------------------------------------------------------------------- 1 | /* United 2 | * Bootswatch 3 | *= require_self 4 | *= require united/loader 5 | *= require united/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/stylesheets/united.css: -------------------------------------------------------------------------------- 1 | /* United 2 | * Bootswatch 3 | *= require_self 4 | *= require united/loader 5 | *= require united/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/stylesheets/united.css: -------------------------------------------------------------------------------- 1 | /* United 2 | * Bootswatch 3 | *= require_self 4 | *= require united/loader 5 | *= require united/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/products/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.id @product.id 2 | json.name link_to(@product.name, product_path(@product)) 3 | json.price number_to_currency(@product.price, unit: "¥") 4 | -------------------------------------------------------------------------------- /chapter_4/shop/db/migrate/20150430090443_add_color_to_variants.rb: -------------------------------------------------------------------------------- 1 | class AddColorToVariants < ActiveRecord::Migration 2 | def change 3 | add_column :variants, :color, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/products/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.id @product.id 2 | json.name link_to(@product.name, product_path(@product)) 3 | json.price number_to_currency(@product.price, unit: "¥") 4 | -------------------------------------------------------------------------------- /chapter_5/shop/db/migrate/20150430090443_add_color_to_variants.rb: -------------------------------------------------------------------------------- 1 | class AddColorToVariants < ActiveRecord::Migration 2 | def change 3 | add_column :variants, :color, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/jobs/order_create_job_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe OrderCreateJob, type: :job do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/mailers/previews/order_mailer_preview.rb: -------------------------------------------------------------------------------- 1 | # Preview all emails at http://localhost:3000/rails/mailers/order_mailer 2 | class OrderMailerPreview < ActionMailer::Preview 3 | 4 | end 5 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/models/order_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Order, type: :model do 4 | it { should belong_to(:user) } 5 | it { should have_many(:line_items) } 6 | end 7 | -------------------------------------------------------------------------------- /chapter_6/shop/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/products/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.id @product.id 2 | json.name link_to(@product.name, product_path(@product)) 3 | json.price number_to_currency(@product.price, unit: "¥") 4 | -------------------------------------------------------------------------------- /chapter_6/shop/db/migrate/20150430090443_add_color_to_variants.rb: -------------------------------------------------------------------------------- 1 | class AddColorToVariants < ActiveRecord::Migration 2 | def change 3 | add_column :variants, :color, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/jobs/order_create_job_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe OrderCreateJob, type: :job do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/mailers/previews/order_mailer_preview.rb: -------------------------------------------------------------------------------- 1 | # Preview all emails at http://localhost:3000/rails/mailers/order_mailer 2 | class OrderMailerPreview < ActionMailer::Preview 3 | 4 | end 5 | -------------------------------------------------------------------------------- /final/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails-practice_session' 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/test/models/product_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_1/shop/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_2/shop/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_3/shop/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/stylesheets/simplex.css: -------------------------------------------------------------------------------- 1 | /* Simplex 2 | * Bootswatch 3 | *= require_self 4 | *= require simplex/loader 5 | *= require simplex/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_4/shop/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_5/shop/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_6/shop/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /final/app/jobs/order_create_job.rb: -------------------------------------------------------------------------------- 1 | class OrderCreateJob < ActiveJob::Base 2 | queue_as :default 3 | 4 | def perform(order) 5 | OrderMailer.confirm_email(order).deliver_later 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /final/app/models/line_item.rb: -------------------------------------------------------------------------------- 1 | class LineItem < ActiveRecord::Base 2 | belongs_to :order 3 | belongs_to :variant 4 | belongs_to :user 5 | 6 | delegate :price, to: :variant, prefix: true 7 | end 8 | -------------------------------------------------------------------------------- /final/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /final/app/views/variants/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@variants) do |variant| 2 | json.extract! variant, :id, :product_id, :price, :size 3 | json.url variant_url(variant, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /final/db/migrate/20150612052304_add_orders_count_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddOrdersCountToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :orders_count, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/simplex.js: -------------------------------------------------------------------------------- 1 | // Simplex 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require simplex/loader 6 | //= require simplex/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/united.js: -------------------------------------------------------------------------------- 1 | // United 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require united/loader 6 | //= require united/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/variants/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@variants) do |variant| 2 | json.extract! variant, :id, :product_id, :price, :size 3 | json.url variant_url(variant, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_2/shop/spec/views/home/index.html.erb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "home/index.html.erb", type: :view do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.footer 2 | .container 3 | %p.text-muted.text-center 4 | 《Rails 实践》#{link_to "http://rails-practice.com/", "http://rails-practice.com/", target: "_blank"} 5 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/variants/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@variants) do |variant| 2 | json.extract! variant, :id, :product_id, :price, :size 3 | json.url variant_url(variant, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_3/shop/spec/views/home/index.html.erb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "home/index.html.erb", type: :view do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/assets/stylesheets/cerulean.css: -------------------------------------------------------------------------------- 1 | /* Cerulean 2 | * Bootswatch 3 | *= require_self 4 | *= require cerulean/loader 5 | *= require cerulean/bootswatch 6 | *= require overrides 7 | */ 8 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/variants/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@variants) do |variant| 2 | json.extract! variant, :id, :product_id, :price, :size 3 | json.url variant_url(variant, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_4/shop/db/migrate/20150612052304_add_orders_count_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddOrdersCountToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :orders_count, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/jobs/order_create_job.rb: -------------------------------------------------------------------------------- 1 | class OrderCreateJob < ActiveJob::Base 2 | queue_as :default 3 | 4 | def perform(order) 5 | OrderMailer.confirm_email(order).deliver_later 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/variants/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@variants) do |variant| 2 | json.extract! variant, :id, :product_id, :price, :size 3 | json.url variant_url(variant, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_5/shop/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails-practice_session' 4 | -------------------------------------------------------------------------------- /chapter_5/shop/db/migrate/20150612052304_add_orders_count_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddOrdersCountToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :orders_count, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/jobs/order_create_job.rb: -------------------------------------------------------------------------------- 1 | class OrderCreateJob < ActiveJob::Base 2 | queue_as :default 3 | 4 | def perform(order) 5 | OrderMailer.confirm_email(order).deliver_later 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/variants/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@variants) do |variant| 2 | json.extract! variant, :id, :product_id, :price, :size 3 | json.url variant_url(variant, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_6/shop/db/migrate/20150612052304_add_orders_count_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddOrdersCountToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :orders_count, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /final/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /final/spec/factories/orders.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :order do 3 | user nil 4 | number "MyString" 5 | payment_state "MyString" 6 | shipment_state "MyString" 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/javascripts/cerulean.js: -------------------------------------------------------------------------------- 1 | // Cerulean 2 | // Bootswatch 3 | //= require jquery 4 | //= require jquery_ujs 5 | //= require cerulean/loader 6 | //= require cerulean/bootswatch 7 | -------------------------------------------------------------------------------- /chapter_2/shop/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_2/shop/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop-with-bootstrap_session' 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_3/shop/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop-with-bootstrap_session' 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails-bootswatch_session' 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails-bootswatch_session' 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails-bootswatch_session' 4 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_4/shop/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop-with-bootstrap_session' 4 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/models/catalog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Catalog, type: :model do 4 | it { should belong_to(:parent_catalog) } 5 | it { should have_many(:subcatalogs) } 6 | end 7 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/line_item.rb: -------------------------------------------------------------------------------- 1 | class LineItem < ActiveRecord::Base 2 | belongs_to :order 3 | belongs_to :variant 4 | belongs_to :user 5 | 6 | delegate :price, to: :variant, prefix: true 7 | end 8 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_6/shop/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop-with-bootstrap_session' 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /chapter_1/shop/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /chapter_1/shop/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_2/shop/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_3/shop/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_4/shop/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_4/shop/db/migrate/20150719071616_add_on_hand_to_variants.rb: -------------------------------------------------------------------------------- 1 | class AddOnHandToVariants < ActiveRecord::Migration 2 | def change 3 | add_column :variants, :on_hand, :integer, default: 0 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/factories/orders.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :order do 3 | user nil 4 | number "MyString" 5 | payment_state "MyString" 6 | shipment_state "MyString" 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /chapter_5/shop/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/factories/orders.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :order do 3 | user nil 4 | number "MyString" 5 | payment_state "MyString" 6 | shipment_state "MyString" 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /chapter_6/shop/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/factories/orders.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :order do 3 | user nil 4 | number "MyString" 5 | payment_state "MyString" 6 | shipment_state "MyString" 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :description, :price, :price 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :description, :price, :price 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :description, :price, :price 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /final/app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

欢迎 <%= @email %>!

2 | 3 |

请点击下面的确认链接,验证您的邮箱!

4 | 5 |

<%= link_to '验证我的邮箱', confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop-with-bootstrap_session' 4 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/views/products/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array!(@products) do |product| 2 | json.extract! product, :id, :name, :price, :description 3 | json.url product_url(product, format: :json) 4 | end 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_shop-with-bootstrap_session' 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/products/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.id @product.id 2 | json.name link_to @product.name, product_path(@product) 3 | json.description @product.description 4 | json.price number_to_currency(@product.price) 5 | -------------------------------------------------------------------------------- /final/app/views/application/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.footer 2 | .container 3 | %p.text-muted.text-center 4 | 《Rails 实践》 5 | = link_to "http://rails-practice.com/", "http://rails-practice.com/", target: "_blank" 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /chapter_3/shop/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | validates :name, presence: true 3 | def to_liquid 4 | { 5 | "name" => name, 6 | "price" => price 7 | } 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

欢迎 <%= @email %>!

2 | 3 |

请点击下面的确认链接,验证您的邮箱!

4 | 5 |

<%= link_to '验证我的邮箱', confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/users/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

你好 <%= @email %>!

2 | 3 |

请点击下面的确认链接,验证您的邮箱:

4 | 5 |

<%= link_to "验证我的邮箱", confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

欢迎 <%= @email %>!

2 | 3 |

请点击下面的确认链接,验证您的邮箱!

4 | 5 |

<%= link_to '验证我的邮箱', confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

欢迎 <%= @email %>!

2 | 3 |

请点击下面的确认链接,验证您的邮箱!

4 | 5 |

<%= link_to '验证我的邮箱', confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

欢迎 <%= @email %>!

2 | 3 |

请点击下面的确认链接,验证您的邮箱!

4 | 5 |

<%= link_to '验证我的邮箱', confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /chapter_1/shop/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Run in docker container 4 | docker run -itd -p 3000:3000 --name shop -v "$PWD":/data -w /data ruby:2.3.3 bash 5 | docker exec -it shop bash 6 | 7 | ## Start rails server 8 | rails s -b 0.0.0.0 9 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/application/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.footer 2 | .container 3 | %p.text-muted.text-center 4 | 《Rails 实践》 5 | = link_to "http://rails-practice.com/", "http://rails-practice.com/", target: "_blank" 6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/application/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.footer 2 | .container 3 | %p.text-muted.text-center 4 | 《Rails 实践》 5 | = link_to "http://rails-practice.com/", "http://rails-practice.com/", target: "_blank" 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/application/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.footer 2 | .container 3 | %p.text-muted.text-center 4 | 《Rails 实践》 5 | = link_to "http://rails-practice.com/", "http://rails-practice.com/", target: "_blank" 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/application/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.footer 2 | .container 3 | %p.text-muted.text-center 4 | 《Rails 实践》 5 | = link_to "http://rails-practice.com/", "http://rails-practice.com/", target: "_blank" 6 | -------------------------------------------------------------------------------- /final/db/migrate/20150602124315_add_columns_to_products.rb: -------------------------------------------------------------------------------- 1 | class AddColumnsToProducts < ActiveRecord::Migration 2 | def change 3 | add_column :products, :top, :boolean 4 | add_column :products, :hot, :boolean 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /final/app/mailers/order_mailer.rb: -------------------------------------------------------------------------------- 1 | class OrderMailer < ApplicationMailer 2 | 3 | def confirm_email(order) 4 | @user = order.user 5 | @order = order 6 | mail(to: @user.email, subject: "您的订单 #{@order.number} 已经确认") 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /final/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/app/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | @import "simplex/variables"; 2 | @import "twitter-bootstrap-static/bootstrap"; 3 | @import "twitter-bootstrap-static/fontawesome"; 4 | @import "simplex/bootswatch"; 5 | 6 | 7 | -------------------------------------------------------------------------------- /chapter_4/shop/db/migrate/20150602124315_add_columns_to_products.rb: -------------------------------------------------------------------------------- 1 | class AddColumnsToProducts < ActiveRecord::Migration 2 | def change 3 | add_column :products, :top, :boolean 4 | add_column :products, :hot, :boolean 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_5/shop/db/migrate/20150602124315_add_columns_to_products.rb: -------------------------------------------------------------------------------- 1 | class AddColumnsToProducts < ActiveRecord::Migration 2 | def change 3 | add_column :products, :top, :boolean 4 | add_column :products, :hot, :boolean 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_6/shop/db/migrate/20150602124315_add_columns_to_products.rb: -------------------------------------------------------------------------------- 1 | class AddColumnsToProducts < ActiveRecord::Migration 2 | def change 3 | add_column :products, :top, :boolean 4 | add_column :products, :hot, :boolean 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /chapter_1/shop/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_2/shop/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 2 2 | 3 | # Run in docker container 4 | docker run -itd -p 3200:3200 --name chp-2 -v "$PWD":/data -w /data ruby:2.3.3 bash 5 | docker exec -it chp-2 bash 6 | 7 | # Start rails server 8 | rails s -b 0.0.0.0 -p 3200 9 | -------------------------------------------------------------------------------- /chapter_2/shop/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_3/shop/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_4/shop/app/models/catalog.rb: -------------------------------------------------------------------------------- 1 | class Catalog < ActiveRecord::Base 2 | has_many :subcatalogs, class_name: "Catalog", foreign_key: "parent_catalog_id" 3 | belongs_to :parent_catalog, class_name: "Catalog" 4 | 5 | has_many :products 6 | end 7 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/variants/new.html.erb: -------------------------------------------------------------------------------- 1 | 4 | <%= render :partial => 'form' %> 5 | -------------------------------------------------------------------------------- /chapter_4/shop/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/mailers/order_mailer.rb: -------------------------------------------------------------------------------- 1 | class OrderMailer < ApplicationMailer 2 | 3 | def confirm_email(order) 4 | @user = order.user 5 | @order = order 6 | mail(to: @user.email, subject: "您的订单 #{@order.number} 已经确认") 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /chapter_5/shop/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/mailers/order_mailer.rb: -------------------------------------------------------------------------------- 1 | class OrderMailer < ApplicationMailer 2 | 3 | def confirm_email(order) 4 | @user = order.user 5 | @order = order 6 | mail(to: @user.email, subject: "您的订单 #{@order.number} 已经确认") 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /chapter_6/shop/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /final/lib/tasks/db.rake: -------------------------------------------------------------------------------- 1 | namespace :db do 2 | task :rebuild => :environment do 3 | Rake::Task["db:drop"].invoke 4 | Rake::Task["db:create"].invoke 5 | Rake::Task["db:migrate"].invoke 6 | Rake::Task["db:seed"].invoke 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /chapter_3/shop/lib/tasks/db.rake: -------------------------------------------------------------------------------- 1 | namespace :db do 2 | task :rebuild => :environment do 3 | Rake::Task["db:drop"].invoke 4 | Rake::Task["db:create"].invoke 5 | Rake::Task["db:migrate"].invoke 6 | Rake::Task["db:seed"].invoke 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /chapter_4/shop/lib/tasks/db.rake: -------------------------------------------------------------------------------- 1 | namespace :db do 2 | task :rebuild => :environment do 3 | Rake::Task["db:drop"].invoke 4 | Rake::Task["db:create"].invoke 5 | Rake::Task["db:migrate"].invoke 6 | Rake::Task["db:seed"].invoke 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /chapter_5/shop/lib/tasks/db.rake: -------------------------------------------------------------------------------- 1 | namespace :db do 2 | task :rebuild => :environment do 3 | Rake::Task["db:drop"].invoke 4 | Rake::Task["db:create"].invoke 5 | Rake::Task["db:migrate"].invoke 6 | Rake::Task["db:seed"].invoke 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /chapter_6/shop/lib/tasks/db.rake: -------------------------------------------------------------------------------- 1 | namespace :db do 2 | task :rebuild => :environment do 3 | Rake::Task["db:drop"].invoke 4 | Rake::Task["db:create"].invoke 5 | Rake::Task["db:migrate"].invoke 6 | Rake::Task["db:seed"].invoke 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /final/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /final/spec/factories/products.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | 5 | factory :product do 6 | sequence(:name){|n| "name#{n}" } 7 | price 9.99 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /final/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | validates :name, presence: true 3 | scope :hot, -> { where(hot: true) } 4 | scope :top, -> { where(top: true) } 5 | has_many :variants 6 | accepts_nested_attributes_for :variants 7 | end 8 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /chapter_1/shop/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_2/shop/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_3/shop/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_4/shop/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_4/shop/spec/factories/products.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | 5 | factory :product do 6 | sequence(:name){|n| "name#{n}" } 7 | price 9.99 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /chapter_5/shop/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_5/shop/spec/factories/products.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | 5 | factory :product do 6 | sequence(:name){|n| "name#{n}" } 7 | price 9.99 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /chapter_6/shop/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_6/shop/spec/factories/products.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | 5 | factory :product do 6 | sequence(:name){|n| "name#{n}" } 7 | price 9.99 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /chapter_1/shop/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/products.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /chapter_2/shop/app/assets/javascripts/variants.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /chapter_3/shop/app/assets/javascripts/variants.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/stylesheets/overrides.css.scss: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 60px; 3 | } 4 | .form-horizontal { 5 | .form-group { 6 | margin-left: auto; 7 | margin-right: auto; 8 | } 9 | } 10 | .navbar-form { 11 | padding-top: 3px; 12 | } 13 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/views/users/sessions/_links.html.erb: -------------------------------------------------------------------------------- 1 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> 2 | <%= link_to t("helpers.links.forgot_password"), new_password_path(resource_name) %> 3 | <% end -%> 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/views/users/sessions/_links.html.erb: -------------------------------------------------------------------------------- 1 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> 2 | <%= link_to t("helpers.links.forgot_password"), new_password_path(resource_name) %> 3 | <% end -%> 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_4/shop/config/locales/models/variant/zh-CN.yml: -------------------------------------------------------------------------------- 1 | zh-CN: 2 | activerecord: 3 | models: 4 | variant: 商品类型 5 | attributes: 6 | variant: 7 | price: 价格 8 | size: 大小 9 | created_at: 添加日期 10 | updated_at: 更新日期 11 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | validates :name, presence: true 3 | scope :hot, -> { where(hot: true) } 4 | scope :top, -> { where(top: true) } 5 | has_many :variants 6 | accepts_nested_attributes_for :variants 7 | end 8 | -------------------------------------------------------------------------------- /final/app/models/catalog.rb: -------------------------------------------------------------------------------- 1 | class Catalog < ActiveRecord::Base 2 | has_many :subcatalogs, class_name: "Catalog", 3 | foreign_key: "parent_catalog_id" 4 | belongs_to :parent_catalog, class_name: "Catalog" 5 | 6 | has_many :products 7 | end 8 | -------------------------------------------------------------------------------- /final/app/views/products/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%- model_class = Product -%> 2 | 5 | <%= render 'form' %> 6 | -------------------------------------------------------------------------------- /chapter_1/shop/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /chapter_2/shop/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop/app/views/products/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%- model_class = Product -%> 2 | 5 | <%= render 'form' %> 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/assets/javascripts/products.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /chapter_3/shop3.1/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def alert_name(name) 3 | case name 4 | when "notice" 5 | "success" 6 | when "alert" 7 | "danger" 8 | else 9 | "info" 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/assets/javascripts/products.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /chapter_3/shop3.2/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def alert_name(name) 3 | case name 4 | when "notice" 5 | "success" 6 | when "alert" 7 | "danger" 8 | else 9 | "info" 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /chapter_3/shop3.3/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def alert_name(name) 3 | case name 4 | when "notice" 5 | "success" 6 | when "alert" 7 | "danger" 8 | else 9 | "info" 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /chapter_4/shop/app/views/products/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%- model_class = Product -%> 2 | 5 | <%= render 'form' %> 6 | -------------------------------------------------------------------------------- /chapter_5/shop/app/views/products/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%- model_class = Product -%> 2 | 5 | <%= render 'form' %> 6 | -------------------------------------------------------------------------------- /chapter_6/shop/app/views/products/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%- model_class = Product -%> 2 | 5 | <%= render 'form' %> 6 | -------------------------------------------------------------------------------- /final/app/views/application/_footer.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /final/app/views/products/new.html.erb: -------------------------------------------------------------------------------- 1 | <%- model_class = Product -%> 2 | 5 | <%= render :partial => 'form' %> 6 | -------------------------------------------------------------------------------- /final/test/fixtures/variants.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | product_id: 1 5 | price: 9.99 6 | size: MyString 7 | 8 | two: 9 | product_id: 1 10 | price: 9.99 11 | size: MyString 12 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootstrap/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_1/shop-with-bootswatch/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /chapter_5/shop/app/models/catalog.rb: -------------------------------------------------------------------------------- 1 | class Catalog < ActiveRecord::Base 2 | has_many :subcatalogs, class_name: "Catalog", 3 | foreign_key: "parent_catalog_id" 4 | belongs_to :parent_catalog, class_name: "Catalog" 5 | 6 | has_many :products 7 | end 8 | -------------------------------------------------------------------------------- /chapter_6/shop/app/models/catalog.rb: -------------------------------------------------------------------------------- 1 | class Catalog < ActiveRecord::Base 2 | has_many :subcatalogs, class_name: "Catalog", 3 | foreign_key: "parent_catalog_id" 4 | belongs_to :parent_catalog, class_name: "Catalog" 5 | 6 | has_many :products 7 | end 8 | -------------------------------------------------------------------------------- /final/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /final/config/sidekiq.yml: -------------------------------------------------------------------------------- 1 | # Options here can still be overridden by cmd line args. 2 | # sidekiq -C sidekiq.yml 3 | --- 4 | :logfile: ./log/sidekiq.log 5 | :verbose: false 6 | :concurrency: 5 7 | :queues: 8 | - [a, 5] 9 | - [b, 3] 10 | - [c, 2] 11 | - [default, 3] 12 | --------------------------------------------------------------------------------