July 16, 2020

Speek - A Rails Social Network

Speek is the name of the project I decided to undertake for my Flatiron School rails final. Speek is a social network that resembles Twitter in some ways, but features longer form posts and user created communities.


  • User profiles with avatars and custom header images.
  • User created communities with roles.
  • Private messaging.
  • Follow and get followed by users.
  • Activity feed to see what people you follow are up to.
  • Posts are formatable in Markdown syntax.
  • Signup via Google/Omniauth.
  • Built with Material Design Bootstrap.
  • And more!

I spent a lot of hours working on this project, especially given the extra time we had due to the holiday break.

For the most part, I'd say the process was pretty smooth. I feel pretty comfortable creating apps like this in Rails, although I know there's a bunch I still don't know.

One of my hangups was on associations of the has many through relationships. I was trying to figure out how to allow a community admin to edit the role of a list of users without having to navigate to an edit page each time they wanted to do this.

At first, I was trying to accomplish this through iterating over the list of User objects, but this was doomed from the start. The solution actually ended up being a lot more simple than I expected. All I needed to do was iterate over the list of memberships. Which were grabbed in my constroller like so @memberships = CommunityMembership.where(community_id: @community.id)

I still haven't quite figured out how to take full advantage of the form builder with this though. The collection tag of the form builder iterates over objects, like Users or Posts. But, I was changing a column on a table. I couldn't figure out how to show the options in a collection tag. So, my solution was to go half form builder/half plain HTML.

  <%= form_with url: community_membership_path(id: membership.id), method: "patch" do |f| %>
<%= f.submit "Change", :class => "btn btn-primary btn-sm" %> <% end %>

I also ran into some issues with Omniauth. My validations required a username, email, and password. Omniauth doesn't set a username or password. So, I had to write a method to handle this myself. It is similar to what is below.

def self.create_with_omniauth(auth)
    create! do |user|
      username = auth['info']['name'].to_s.split
      username = username[0] + rand(100..1000).to_s

      user.provider = auth['provider']
      user.uid = auth['uid']
      user.username = username
      user.email = auth['info']['email']
      user.password = auth["uid"] + username
      if auth['info']
         user.name = auth['info']['name'] || ""

Like I said, overall, this project was pretty fun. When I ran into trouble, I was able to find the solution through Google or through the help of some friends in my cohort. Can't wait for the next project!

If you'd like to checkout Speek, you can do so at: https://speek-rails.herokuapp.com/. My video walkthrough is also posted below. Hope you like it!

tags: speek social-network code ruby rails