Plan for solving a challenge in Rails

Serena Bright
Aug 7, 2019 · 1 min read

Basic setup for the app:

1. read the instructions all the way through till the last word. You might be surprised the relationships are not what they seem at first

2. draw the relationship out on a paper or whiteboard

3. run in the terminal, whatever is needed:

a. rails g model & rails g controller, or

b. rails g resources

4. rollback all schema

5. add any missing attributes to the tables, or, better, run migrations to add those

6. add any missing relationships to classes (has_one/has_many/belongs_to)

rails g migration add_category_id_to_expenses category_id:integer
rake db:migrate

7. run migration(s) adding foreign keys to the join molel (if many-to-many)

8. run all migrations so they are reflected in the schema

9. check the routes: usually, it’s best to set them up as resources: model-name

10. check the schema again

11. seed

12. test in the console (Dog.all, Dog.count)

An overall method for every single deliverable is:
1. read it
2. break it down into steps
3. what is the user’s experience? — go to views
4. what my controller needs to do to enable #3? — controller actions
5. where does it redirect? — routes
6. test it
7. put a check smiley to your list of deliverables and move on to the next

Serena Bright

Discovering the whys and hows to living a meaningful and fun life despite the obstacles

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade