Giter VIP home page Giter VIP logo

rails5-api-only-app's Introduction

STEPS GET DONE

1. Creating and Setting Up

rails new ecommerce --api -d postgresql -T

2. Setting API subdomain in routes.rb

Rails.application.routes.draw do constraints subdomain: 'api' do end end

3. Creating book model

rails g model Book title:string author:string weight:string publisher:string language:string pages:integer publication_date:datetime

4. for create the database

rake db:create

5. to create book table

rake db:migrate

6. Setting API Versioning

gem 'versionist' in GEMLFILE RUN rails generate versionist:new_api_version v1 V1 --path=value:v1

7. adding api_versioning in namespace under routes.rb

api_version(:module => "V1", :path => {:value => "v1"}) do end

8. for creating routes for books CRUD in routes.rb add:

resources :books

9. create the books controller inside version 1

path: app/controllers/v1/books_controller.rb

10. OPEN rails c

RUN Book.create(title: "Atlas Shrugged", author: "Ayn Rand", weight: "3.4 pounds", publisher: "Dutton", language: "English", pages: 1168, publication_date: "April 21, 2005")

11. Now just start your rails server and go to your postman and

GET http://api.localhost:3000/v1/books

12. Creating the others actions (Create, Show, PUT/Patch, Delete)

mentioned in app/controllers/v1/books_controller.rb

rails5-api-only-app's People

Contributors

muhammadawaisshaikh avatar

Watchers

 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.