Giter Site home page Giter Site logo

rest-api-rails's Introduction

SIMPLE REST API use Rails 5

Technology

INSTALL DEPENDENCIES

$ bundle install

CREATE DATABASE

$ rake db:create

RUN MIGRATION

$ rake db:migrate

MAKE DUMMY DATA

$ rake db:seed

RUN SERVER

$ rails s

Tes using Postman Create Article

http://localhost:3000/api/vi/articles
choose content type and application/json in Headers

choose Body and type use json

{
	"title": "Article from postman third",
	"body": "Lorem Ipsum asas "
}

If success it will return like json format

{
    "status": "SUCCESS",
    "message": "Saved article",
    "data": {
        "id": 9,
        "title": "Article from postman third",
        "body": "Lorem Ipsum asas ",
        "created_at": "2017-08-09T10:30:38.738Z",
        "updated_at": "2017-08-09T10:30:38.738Z"
    }
}

Show All article

Methode GET

http://localhost:3000/api/v1/articles

and will return json format

{
    "status": "hoho Sukses",
    "message": "Loader article",
    "data": [
        {
            "id": 7,
            "title": "Article from postman",
            "body": "Lorem Ipsum",
            "created_at": "2017-08-09T10:29:50.978Z",
            "updated_at": "2017-08-09T10:29:50.978Z"
        },
        {
            "id": 6,
            "title": "as",
            "body": "as",
            "created_at": "2017-08-09T10:29:06.283Z",
            "updated_at": "2017-08-09T10:29:06.283Z"
        },
        {
            "id": 5,
            "title": "Butter In a Lordly Dish",
            "body": "Accusantium ut modi quis amet.",
            "created_at": "2017-08-09T08:03:07.171Z",
            "updated_at": "2017-08-09T08:03:07.171Z"
        },
        {
            "id": 4,
            "title": "The Golden Apples of the Sun",
            "body": "Occaecati architecto facilis expedita.",
            "created_at": "2017-08-09T08:03:07.170Z",
            "updated_at": "2017-08-09T08:03:07.170Z"
        },
        {
            "id": 3,
            "title": "As I Lay Dying",
            "body": "Necessitatibus sed iusto quis mollitia aspernatur reprehenderit consequatur omnis.",
            "created_at": "2017-08-09T08:03:07.168Z",
            "updated_at": "2017-08-09T08:03:07.168Z"
        },
        {
            "id": 2,
            "title": "I Will Fear No Evil",
            "body": "Voluptates laudantium facilis cumque rerum fuga iusto.",
            "created_at": "2017-08-09T08:03:07.166Z",
            "updated_at": "2017-08-09T08:03:07.166Z"
        },
        {
            "id": 1,
            "title": "The Road Less Traveled",
            "body": "Rerum alias non pariatur perspiciatis quasi odit.",
            "created_at": "2017-08-09T08:03:07.146Z",
            "updated_at": "2017-08-09T08:03:07.146Z"
        }
    ]
}

Show One or custom article

Methode GET

http://localhost:3000/api/v1/articles/article_id
example
http://localhost:3000/api/v1/articles/1

will return json format

{
    "status": "hoho Sukses",
    "message": "Loader article",
    "data": {
        "id": 1,
        "title": "The Road Less Traveled",
        "body": "Rerum alias non pariatur perspiciatis quasi odit.",
        "created_at": "2017-08-09T08:03:07.146Z",
        "updated_at": "2017-08-09T08:03:07.146Z"
    }
}

rest-api-rails's People

Contributors

muhammadyana avatar bekicot avatar

Stargazers

M Yasfi Fauzie avatar  avatar Wicky 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.