Why I Chose to Create a ToDo List Project with Full Stack Rails (And Then Some)
A ToDo List application seems like a pretty beginner project, right? It can be. It can also become something much more. I plan to use my weekly blog posts to highlight some of learning and experimentation I am doing.
Disclaimer: My blog series on my projects will be making the assumption you have some experience with Ruby and Rails and any other language/framework that comes up. These blogs also are primarily a way for me to write down some of my learnings in my own words as a way to reinforce and retain what I have learned.
There are several reasons why I chose to do something a bit simpler this time around:
1. I haven’t created a project in Rails using scaffolding. I have started some things this way just to see what it did, but I haven’t gone through to the finish with scaffolding.
2. HTML/CSS — let’s just say I haven’t spent a ton of time here. This project is being done intentionally to work on this area and learn some new things. Scaffolding from the beginning gives me a nice mix of ERB and HTML. This gives me some basic HTML examples as a starting point.
3. I am very much not a designer. Having a basic setup removes the initial obstacle in my brain that wants to know what to put where. The initial “design” that comes with scaffolding a project gives me an idea and I can then play with the design and move things around from there. I haven’t decided what I will/won’t move at this point, but we will see as I progress through this different type of learning experience I am creating.
Scaffolding:
In Rails, once you have started your project (rails new [project_name]), you can then run “rails g scaffold” followed by what you want to create. I used “lists” (rails g scaffold lists description:string completed:boolean). I added description and completed to my command in order to add them to the lists table from the beginning. Note: I also added “false” as a default to “completed” prior to migrating the database (see example).
This creates several things:
•ListsController
•List model
•resources :lists (config/routes.rb)
•files in app/views/lists
•various testing files
Once you have scaffolded your project, in your terminal, run “rails db:migrate” to set up your schema in your database. Now, get ready for something really cool…in your terminal run “rails s” and open your browser and go to “localhost:3000”.
You have a fully functioning front end in addition to backend/database. Is this what you want your end result to look like? Probably not. However, as stated previously, part of this exercise is to create a low stress way to work on some front end skills.
A couple of notes so far:
•Don’t forget to open localhost:3000/rails/routes in a browser tab so you have your list of routes handy.
•Don’t forget to set your root path to something other than the “Welcome to Rails”
•Scaffolding is going to create all kinds of files that you likely won’t need. Don’t forget to go through your files when you are cleaning up a scaffolded project and clean up unnecessary files. (I am hoping that writing this now will remind me to do it later — I have always been a bit nervous with just deleting files for some reason.)
Next week I plan to take a jump into CSS and see if I can untangle why I haven’t done much in this area before other than styling and front end are a bit more ethereal to me versus the backend that feels a bit more solid.