Giter Site home page Giter Site logo

mod-two-week-one-review-london-web-102819's Introduction

Seven Seas: Sinatra and Rails Comparison

Seven seas...
Seven restful routes...
Seven days of studying web frameworks...
And now it's time to review with a Sinatra to Rails challenge!

What You Have Now

You've been provided with the Sinatra Seven Seas application. It has full CRUD actions for the resource 'sea' and an MVC framework. Take a few minutes to look through the app and familiarize yourself with the code. Then, fire up shotgun in terminal and see how it looks!

Notice all the fancy styling? That comes from a popular front-end styling framework called Bootstrap. If you look in 'app/views/layout.erb', you'll see the Bootstrap styling linked. All of the css classes used in the application come from Bootstrap.

Don't worry if the styling seems a bit magical right now; your focus will be mainly on the MVC structure.

Goal

Your job is to recreate the Seven Seas application in Rails. To a user, the Sinatra and Rails apps should be indistinguishable.

Feel free to copy/paste where applicable from Sinatra to Rails. While copy-pasta is usually discouraged in labs, the goal of this lesson is to become aware of the similarities and differences between Rails and Sinatra applications.

Caveats and Tips

  • In order to give your Rails Seven Seas Bootstrap styling, simply copy the two bootstrap stylesheet lines from the Sinatra 'app/views/layout.erb' head, and move them to 'Rails-Seven-Seas/app/views/layouts/application.html.erb'.
  • We've built Rails new and edit forms for you, since Rails forms have some built-in security features with conventions we have to follow. Once you get the form views rendered in your browser, inspect the HTML to see what is being generated by Rails's form_for.
  • Use rails s to start a server and rails c to enter a console. Confirm your assumptions early and often!

Instructions

  • Where do we start with any Sinatra or Rails application? bundle install, of course! Next, run rails s and go to http://localhost:3000/, to see a welcome page. Woohoo, you're on the Rails!
  • You'll need a database populated with the seven lovely seas from the Sinatra application. Think about what code can be recycled from the Sinatra app's db folder.
  • In Rails, routes are separated from controllers. Because Rails is awesome, the routes.rb file contains a link to the Rails documentation for routes. Since you're building full CRUD for a sea, add all seven RESTful routes to this file.
  • Now, your job is to work out the MVC--Model, View, Controller--part of this app. When making your model, controller, and views, remember that naming conventions are very important in Rails!
  • You will have to do some research to implement the delete functionality. Check out how the delete is built in Sinatra and think about why the same approach won't work in Rails.

Stuck?

  • Run rake -T to see your rake tasks
  • Run rails c to check and update your data
  • Run rails s and test your code in the browser
  • Use byebug (it's just like pry) to check your controller actions
  • Check the (excellent) Rails documentation or Google the error

Bonus

Uh oh, the Rails forms have no styling! Check the Rails documentation to see how to add css styling to Rails forms.

mod-two-week-one-review-london-web-102819's People

Contributors

dependabot[bot] avatar graciemcguire avatar ihollander avatar maxwellbenton avatar notnotdrew avatar rachelsa avatar sgharms avatar telegraham avatar timothylevi avatar

Watchers

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