Code Monkey home page Code Monkey logo

tdt4242-shop's Introduction

TDT4242 Shop

A running copy of the project can be found at https://tdt4242eshop.azurewebsites.net/.

What's included?

  • Devise for authentication
  • Pundit for authorization
  • Bootstrap v3 for layout and styles
  • Administrate as an admin dashboard for database entries
  • Sqlite as database
  • Embedded Ruby as template engine

Project structure

The app folder contains the actual application. All other folders fulfill necessary support functions, e.g. configuration for deployment.

In the app folder, we have several subfolders:

  • assets contains all images, stylesheets and JavaScript files that our application uses.
  • The controllers folder contains one Ruby file per model that our application uses. On top of that, there is an ApplicationController (for things relevant to the entire application) and several controllers for our database admin dashboard Administrate.
  • The dashboards, you find the definition of all Administrate dashboards that are shown in the admin area. These files are necessary to define the fields that are displayed in a dashboard.
  • Helpers are used in RoR to accommodate more complex functions that fit neither in a controller nor in a model. They help to keep controller and model files concise and tidy.
  • We use mailers to communicate with users of our application. Emails concerned with user matters (email confirmation etc.) are carried out by the TdtMailer class. Emails that are specifically concerned with orders, are sent via the StatusMailer. The ApplicationMailer provides a common base class for both of them.
  • All models have a Ruby class in the models folder. This is where relationships between models and requirements to any fields (e.g. price must be numeric) are established and validated.
  • The policies folder has one file per model. A policy is used by Pundit to determine whether a user is authorized to access a certain resource or not.
  • Services are used during database setup. We establish our three default users (admin, seller, customer) using a service each. The services get the pre-defined credentials from so-called secrets.
  • The views folder contains all Embedded Ruby files that are later converted to HTML files. The subfolder structure mostly follows our model structure. The devise folder contains views that are specific to authentication with Devise. The layouts folder holds common views, such as the general application template and the navigation bar.

Running the project

Development was done with the following versions:

  • Ruby 2.5.0
  • Rails 5.1.4

Other versions should work fine, as long as they are not too old (or too recent).

Run bundle install.

Run rails server.

Run rake db:setup.

In case you have run the project before, you may need to run rake db:migrate before rake db:setup. Your command line should tell you about this with a message along the lines of "there are migrations outstanding".

The application should now be available at localhost:3000.

Default users are:

tdt4242-shop's People

Contributors

alex2702 avatar erikkvam avatar torbjoks avatar

Watchers

 avatar  avatar

Forkers

torbjoks tobinus

tdt4242-shop's Issues

Error when registering new customer account

This happens when ran locally, and I try to create a new user account, check if it is still an issue in the tool chain.

`ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):

1: Welcome <%= @email %>!\n

2: You can confirm your account email through the link below:\n

3: <%= confirmation_url(@resource, confirmation_token: @token) %>`

Error when trying to access order management

This happens when ran locally as and I try to access the order management.

SyntaxError (/home/ec2-user/environment/tdt4242-shop/app/controllers/orders_controller.rb:66: syntax error, unexpected keyword_rescue, expecting keyword_end
rescue ActiveRecord::ActiveRecordErr
^
/home/ec2-user/environment/tdt4242-shop/app/controllers/orders_controller.rb:66: syntax error, unexpected =>
veRecord::ActiveRecordError => e
^
/home/ec2-user/environment/tdt4242-shop/app/controllers/orders_controller.rb:118: syntax error, unexpected keyword_end, expecting end-of-input):

app/controllers/orders_controller.rb:66: syntax error, unexpected keyword_rescue, expecting keyword_end
app/controllers/orders_controller.rb:66: syntax error, unexpected =>
app/controllers/orders_controller.rb:118: syntax error, unexpected keyword_end, expecting end-of-input

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.