Coder Social home page Coder Social logo

rails_engine_fe_7's Introduction

Consuming your Rails Engine API

Congratulations! You've written your first API. Just like the API you consumed for your week 1 project, your Rails Engine API can be used by other projects now, too. For this challenge, you will create a front end application that will make calls to your backend application, the Rails Engine API you have just created.

Setup

Just like your week 1 project, this will be a new Rails app. You should fork this repository.

git clone <Rails Engine FE SSH>
cd rails_engine_fe
bundle
bundle exec rake db:create

In /config/puma.rb, you'll notice that the port has changed from 3000 to 5000. This should be on or around line 12.

We do this because Rails Engine is not in production or hosted somewhere other than localhost. If Rails Engine is running on port 3000, our front end will need to have a different port so they can run at the same time. Now, when we do rails s, our front end application will automatically use port 5000. You can also do this manually every time you start your server by passing the port number with a -p flag like so: rails s -p 5000. You should see that your server is "listening on tcp://localhost:5000" now instead of the usual 3000.

port        ENV.fetch("PORT") { 5000 }

In order for your frontend to properly get data from your backend Rails Engine API, you must keep your backend server running locally at the same time.

The Challenge

User Story - Merchants

As a visitor,
When I visit '/merchants'
I should see a list of merchants by name
and when I click the merchant's name
I should be on page '/merchants/:id'
And I should see a list of items that merchant sells.



Wireframe for /merchants index



Wireframe for /merchants show

Extra Practice

If you have time or want extra practice, complete this user story for Items

User Story - Items

As a visitor,
When I visit '/items'
I should see a list of items by name
and when I click the item's name
I should be on page '/items/:id'
And I should see the name of the item, description, and unit price.

Extension Ideas

  • Create a search form on your root path to consume one of your part 2 endpoints to search for one merchant or all merchants by a name fragment

Wireframe for /merchants show

Learning/Review Goals:

  • Practice TDD
  • Consuming an API
  • Gain familiarity with service oriented architecture

rails_engine_fe_7's People

Contributors

sandfortw avatar abdulredd 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.