Today I decided to build a microblog app. It is like a traditional blog, but it is private to a specific group of friends. There are other options out there for a microblog, but I wanted to create the experience for myself, and how I would customize it for my group of friends. After I finish the app, I plan to release it to my friends from college, and see what their feedback is.
I started out by creating a new app via rails. For the moment, I am calling the app “microhaus.” I came up with this name particularly because it’s a microblog, and it is accessible only to a small number of people (a circle of friends, if you will).
I then made changes to the Gemfile in order to reflect the gem and database preferences. This is what my gemfile currently looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
I’ve set up my test, development, and production environments. Later on, I will add in other gems in order to enhance microhaus, but for the initial buildout process, these gems will do.
I also created a User scaffold, which instantiates a migration for User, a controller, resources, erb templates, stylesheets, and tests. After creating the scaffold, I ran the
rake db:migrate command in order to migrate the Users table into the development database.
Secondly, I added a Post scaffold via the
rails g scaffold Post content:string user_id:integer group_id:integer command. The idea is to have a post that belongs to a user, and can be viewed by a group in which the users have the corresponding group id. We want each post to be viewable by users of the same group.
At this point, I committed and pushed my changes up to Github.
The next step is to build out a secure token generator that will be used to verify cookies when a new login session is initialized. Here’s the code I used to set this up:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
My approach to building an application closely mirrors that of Michael Hartl’s approach, so as he recommends, this would be a good time to start writing out some tests. I wrote out RSpec tests to make sure the “About, Home, and Contact” pages properly render as specified in my ERB templates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
At this point, we have the basic building blocks in place that are necessary to horizontally plan out our application structure. Once that structure is in place, then we can start building the application vertically, and make changes/additions as necessary.
The next step is to start building out the functionality for the ERB templates and also to build out the corresponding RSpec tests to ensure that the functionality is there. These concepts will be covered in the next “Microhaus” post.