Create sinatra routes
Note: if you get stuck review Sinatra with Active Record: POST/PATCH/DELETE Requests Note:
bundle exec rerun -b 'rackup config.ru'
will run your server. Note:npm start
inside the client folder will run your client server
- Clone down the starter code and run bundle and migrate. Verify your migration was successful.
In client folder review the code in app.js. Discuss the code with your group, what is it doing? Next run run npm i
Start your client with npm start
. Notice the error here (DO NOT try to debug, this will be fixed as we build out the activity) Why do you think this is erroring out?
Review your models to verify the associations are set up correctly. Create some seeds manually or using the faker gem.
- In the controller folder create
tickets_controller.rb
. Create aTicketsController
class that inherits fromApplicationController
.
- Find
config.ru
in the root. Mount your controller by addinguse TicketsController
underrun ApplicationController
- In the tickets controller create a
/tickets
get route that response with all of the tickets. Include the movie association with each ticket. If you've done this correctly and have your backend and client running, you should see your tickets in the browser.
- Create a delete route that will delete a ticket. Find the ticket using params and delete the ticket. Send a hash with a message that the ticket has been removed.
- On the client side, in App.js create a handleDelete function that will call a delete fetch when the delete button is clicked and remove the ticket from state.