GithubHelp home page GithubHelp logo

macodingclub / bartevian Goto Github PK

View Code? Open in Web Editor NEW
0.0 7.0 2.0 2.38 MB

antique store

Ruby 54.99% JavaScript 1.82% CoffeeScript 17.06% CSS 3.46% HTML 22.29% Roff 0.39%
rails bootstrap database devise

bartevian's Introduction

Generate connected DB and Model from the command line

rails g model Book title:string description:text author: string price:integer

Book's Model is singular(book) and in the db is plural(books)

Create database from migration file

rake db:migrate

Start server

rails s

Generate controller from the command line

rails g controller Books

Check routes for the app

rake routes

In routes.rb file , create a restful route

resources :books

In routes.rb file defining the root of the application

root ‘books#index’

Install the gems, every time needs to be run when we installing new gems

bundle install

Install simple_form gems with incorporated bootstrap

rails g simple_form:install –bootstrap

Install gem devise for login, logout

gem 'devise', '~> 4.2'

rails g devise:install

rails g devise:views

rails g devise User

Update DB with the new USER tables

rake db:migrate

Create relashions between user_id and items

rails g migration add_user_id_to_items user_id:integer

Connect with the DB through the console. Item is the DB-table

rails c

Item.connection

Item – see all fields and types of fields

Item.first | Item.last | Item.find(3) – find by id

Create variables with results from the DB query

rails c

Item.connection

@book = Item.last

@item.user_id = 1

@item.save

In show.html.erb- Add the logic if the user is login

<% if user_signed_in? %>

<% if @item.user_id == current_user.id %>

<%= link_to “Edit”, edit_item_path(@item) %>

<%= link_to “Delete”, item_path(@item), method: :delete, data: { confirm: “Are you sure” } %>

<% end %>

<% end %>

Connect with the DB through the console and add Categories manually

rails c

Category.connection

Category.create(name: “Art”)

Write pure SQL to the DB

rails db

.tables

README

This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Ruby version

  • System dependencies

  • Configuration

  • Database creation

  • Database initialization

  • How to run the test suite

  • Services (job queues, cache servers, search engines, etc.)

  • Deployment instructions

  • ...

PostgreSQL local configuration:

=========================================== sudo apt-get install postgresql export DATABASE_URL=postgres:///$(whoami) sudo -u postgres createuser -s $(whoami); createdb $(whoami) bundle install

=========================================== to completely remove postgreSQL: ps -C postgres ...if shows processes, then: sudo killall postgres ps -C postgres …if there are no mo running processes, then:

sudo apt-get --purge remove postgresql* sudo rm -r /etc/postgresql/ sudo rm -r /etc/postgresql-common/ sudo rm -r /var/lib/postgresql/ udo userdel -r postgres sudo groupdel postgres

===========================================

bartevian's People

Contributors

plamen1982 avatar plamenjetchev avatar vgrozev avatar mirka74bg avatar

Watchers

James Cloos avatar  avatar  avatar  avatar Dimitri Matev avatar  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.