Giter Site home page Giter Site logo

bookstore's Introduction

Bookstore Application

Project description & features

  • Browse books by category
  • Books have authors and publishers
  • Bootstrap layout is used
  • Books, categories, author and publishers can be added, edited and removed from the frontend

What I learned with this project

  • Rails & MySQL setup
  • Controllers & Views
  • Application layout
  • Models & databases
  • Creating all elements (authors, publishers, books and categories)

This app can be built either on Windows or Linux workspaces. There are a few differences, though, as explained below:

Linux installation

Install the dependencies and devDependencies and start the server.

$ sudo apt-get update
$ apt-get upgrade
$ apt-get install curl
$ \curl -L https://get.rvm.io | bash -s stable

Now it's required to put user and password of your root user (Run as bash). After that, run

$ source ~/.rvm/scipts/rvm
$ rvm requirements
$ rvm install ruby
$ rvm use ruby --default
$ rvm rubygems current
$ gem install rails

Now check if Ruby and Rails are installed:

$ ruby -v
$ rails -v

Setting up the envinroment

I installed an apache server along with PHP and MySQL, but they are not required. I used only to have access to MySQL database (which is not required) and to access phpMyAdmin, to manage the database. But it's up to you.

$ sudo apt-get install lamp-server^
$ apt-get install libmysqlclient-dev
$ apt-get install phpmyadmin

To fix a warning about ServerName localhost, do this:

$ sudo nano /etc/hosts

Check the host name and copy it.

Open this

$ sudo nano /etc/hapache2/apache2.conf

Scroll down to the last line and add these two lines:

$ Include /etc/phpmyadmin/apache.conf
$ ServerName ubuntu

Restart apache:

$ sudo service apache2 restart

Get inside MySQL now to create databases or do this inside phpMyAdmin. I created:

Databases
bookstore_development
bookstore_test
User
bookstore

Development

Use bash permanently inside terminal:

Open Profile preferences > Title and commmand Enable: Run command as login shell

Install mysql adapter and NodeJS to take care of javascript inside ruby:

$ gem install mysql2
$ sudo apt-get install nodejs

If you don't want to install NodeJS, run these commands instead:

$ gem install mysql2
$ gem install therubyracer
$ gem install libv8 --version=3.11.8.3
$ gem install execjs

Create application

With the terminal, get into a folder to host the project and run

$ rails new bookstore
$ cd bookstore
$ bundle install

Edit the file "Gemfile" now. Uncomment therubyracer line, comment sqlite3 line and use instead

gem 'mysql2'

Edit database configurations. Change from :

bookstore/config/locales/database.yml

default: &default
  adapter: mysql2
  pool: 5
  timeout: 5000

development:
  <<: *default
  adapter: mysql2
  database: bookstore_development
  username: bookstore
  password: bookstore
  
test:
  <<: *default
  adapter: mysql2
  database: bookstore_test
  username: bookstore
  password: bookstore

Run bunlde install again from terminal

$ bundle install
$ rails server

Verify the deployment by navigating to your server address in your preferred browser.

localhost:3000

Run the code below to create tables inside the databases that were created above

$ rake db:migrate

Now you can run the application from this repository without any problem

Todos

  • Write MORE Tests
  • Add tutorial for installation on Windows 10
  • Add a translated version of this README to portuguese

License

GPL v3

bookstore's People

Contributors

andreszlima avatar

Watchers

James Cloos avatar  avatar

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.