Giter Club home page Giter Club 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.

Learning/Review Goals:

  • Practice TDD
  • Consume an API
  • Gain familiarity with service-oriented architecture

Setup

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

git clone <your forked copy of this repo>
cd rails_engine_fe
bundle
bundle exec rails 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

1. Merchants Index

As a visitor,
When I visit '/merchants'
I should see a list of merchants by name
and each merchant's name is a link to their show page (merchants/:id).



Wireframe for /merchants index



2. Merchants Show

When I visit the merchants index page (/merchants)
and I click a merchant's name
I should be on page '/merchants/:id'
And I should see that merchant's name and a list of items that merchant sells.



Wireframe for /merchants show



3. Items Index

As a visitor,
When I visit '/items'
I should see a list of item names,
and each name is a link to that item's show page (/items/:id),
and when I click on that link, I am taken to that item's show page
where I see the name of the item, its description, and unit price.



Extra Practice

If you have time or want extra practice, complete the following user stories that match the "Find One" and "Find All" endpoints of your backend project's "Section Two" requirements.

4. Find One

As a visitor,
when I visit /search,
I see a form that allows me to search for a single Merchant (or a single Item) by its name.

5. Find All

As a visitor
when I visit /search,
I see a form that allows me to search for all Merchants (or Items) by name, min_price, or max_price.

Wireframe for Search Page

rails_engine_fe_7's People

Contributors

abdulredd avatar cjsim89 avatar

Watchers

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