Giter VIP home page Giter VIP logo

restaurant-app's People

Contributors

vadimvny avatar

Watchers

 avatar  avatar

restaurant-app's Issues

parameter naming

From a code communication standpoint, we would prefer params[:order] to params[:orders] as the has represents attributes to be updated for a single order, not many orders.

# app.rb:143 
patch '/orders/:id' do
    order = Order.find(params[:id])
    order.update(params[:orders])
    redirect '/orders'
end

No README

Without a README, people might not know what this project is, and are therefore much less likely to use it or contribute to it.

In addition, in three months' time, when you come back to it, not having a README will mean that you will have to relearn all about the code from scratch.

Creating orders inside of party#create action.

It does not make sense to create orders inside of this action. Moreover, it looks like params[:orders] will be nil, given the form in parties/new.erb.

# app.rb:79
post '/parties' do
    party = Party.create(params[:parties])
    orders = Order.create(params[:orders])
    redirect '/parties'
end

remove breakpoints from production code

post '/parties/:party_id/orders' do

    Order.create({
        party_id: params[:party_id],
        food_id: params[:food_id]
    })
    binding.pry #=> This will cause your application to stop working when an order is created.  This is probably not the desired functionality.  :)
    redirect "/parties/#{params[:party_id]}"
end

variable naming

# app.rb:58
get '/parties' do
    @parties = Party.all
    @order = Order.all  #=> This is a little confusing, variable name should be @orders as Order.all returns an array of Order objects, not just a single one.  
    erb :'parties/index'
end

No error handling if order is created and party has checked out

There should be some error raising and handling that prevents orders from being created when a party has checked out.

post '/parties/:party_id/orders' do

    Order.create({
        party_id: params[:party_id],
        food_id: params[:food_id]
    })
    binding.pry
    redirect "/parties/#{params[:party_id]}"
end

Variable naming

# app.rb:115
get '/orders' do
    @orders = Order.all
    @party = Party.all  #=> Party.all returns an array of party objects.  Variable should be named @parties to reflect the fact that we are dealing with many parties, not just a single one.
    erb :'orders/index'
end

Fix name of repo

I think it should be RESTaurant-App instead of RESTaraunt-App

paramater propblems

Unless you are submitting parameters in a query string, it looks to me like this route will error out.

get 'parties/:id/orders' do
    # this line should be 
        # @party = Party.find(params[:party_id])
        # like this line 
        @ part = Party.find(params[:id])
    @orders = Party.find(params[:orders])  #=> this line doesn't make sense.  Isn't `params[:orders]` nil?  If you are trying to get a given parties orders, simply call `@party.foods`
    erb :'orders/index'
end

checkout route doesn't appear to work

This should modify some attribute on your party record to signify that the party has paid.

# app.rb:159
patch '/parties/:id/checkout' do

    erb :receipt
end

Route confusion

This route is only responsible for rendering a new form. Not actually creating an order resource. Moreover, unless you are submitting parameters in a query string, params[:id] will return nil. Also, you should remove extraneous comments from your production code.

# app.rb:21
get '/orders/new' do
    @food = Food.all
    @order = Order.create(params[:id])
    #@party = Party.find(params[:id])
    erb :'orders/new'
end

Commit messages

Your commit messages are short, but it's because you are summarizing a lot of work, instead of describing a small amount of work. You should strive to do small amounts of work in each commit.

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.