My rails project, Roommate Assistant

Posted by WilliamMena on March 18, 2017

So I’ve finally gotten to the end of Rails and I truly feel like I’ve learned a lot. I’m reaching the point where I feel like I can truly build something cool (with enough time for experimentation). I have the tendency to overdue when unnecesary so in this project I tried to not go too overboard before too much time has passed and my head explodes. I will say though, bare with me throughout this project. I wanted to focus on getting a full application working first. I did find out that our next big project is to redo this application but with a javascript front end, so I wanted to leave my look for later on. Right now I just have the core application functioning and when I get javascript downpacked, I’ll then proceed to adding some css or bootstrap.

What is Roommate Assistant?

I wanted to create a list application where you can create lists that can be shared with your roommates. The core idea would be create a shopping list and a chores list viewable to only your roommates, and once accomplished or bought, anyone can mark it off as complete. Chores can be assigned to specific roommates as well, while the shopping list is made for everyone.

Features

Homepage

The main features were revolved around a ton of associations. Once you sign in, you reach a homepage that will present to you a list of all your ‘lists’. To avoid confusion of the list type, below it tells you if it’s a chores or shopping list but the title of the list will be a link directing you to the list you created. Below this (or when some css is implemented, next to this) there will be a section with the title ‘Lists you’re shared on’ which is pretty self explanatory. This are the lists that are created by your roommates that you can view, because they shared you on this list. The moment the owner of the list decides to unshare you, you lose access.

The NEXT section is the section associated to what I usually struggle the most with. I’ve heard this referred to as “aliasing” before but when I search the internet for this technique, I find the term Self-Referential Association used. Or I just find more people referencing this Rails Cast. And for any Rails enthusiasts who have never heard of Rails Casts, stop reading this blog and go check it out. I’m totally serious. And don’t feel bad if you don’t want to donate for their PRO videos. They’ve uploaded them to youtube already. But back to Self-Referential Associations. I used this on my last project because I find this day and age, most to all applications have a ‘social’ feature. And what I mean by that is the feature of adding ‘friends’ or ‘followers’. And one way you can implement this type of feature is by creating your original User model and then a Friend model, which is what I thought I needed to do my first time around. But that was a nightmare. What I actually did was use one User model and used these next very important lines. You reference the User class by an ‘alias’ or a different name but still need to acknowledge it’s a User class.

has_many :friendships
has_many :friends, :through => :friendships
has_many :inverse_friendships, :class_name => "Friendship", :foreign_key => "friend_id"
has_many :inverse_friends, :through => :inverse_friendships, :source => :user

I won’t get too into the technique, but I highly recommend dabbling with it. The first time I used this feature it took me awhile to get it right but this time around implemented it pretty quickly and was able to modify it much more to my liking. Reading and practicing are two very different things.

But the next section on my home page that I was talking about, before wandering off, was your pending roommate requests. My last project, which I might refer to at times as my ‘Recipe Social Media project’ has a kind of ‘follower’ relationship. Where you can view everyone’s page but if you follow someone, they appear on your ‘feed’. This time around I implemented a more of a friendship type of relationship. For each of you to view content, you both have to decide to be friends. One sends a roommate request and the other accepts. So in this section you can see the people who are requesting you, which I thought would be easier or more convenient for the users.

List

Once on the list page, you’ll see a pretty simple UI. Title, creator, and the list if it has any content. From this page you can create items to be added to this list. For groceries it’s as simple as typing what every item you want to buy and clicking submit (or pressing enter). For chores, you can type in what needs to be done and assign it to one of your roommates (or yourself, don’t be lazy, do your chores) if applicable. Your roommates can view and modify the items as well. If an item is bought or a chore is done, anyone can click ‘Buy’ or ‘Complete’ and it will cross the item off. If the user created the list, only that user can delete an item or the list as a whole. User can edit the people who view the list or edit the title of the list.

Adding Roommates

In the navigation, there will be a link with either the text “Add Roommates” or “Roommates”. If you currently don’t have any available, “Add Roommates” will take you to the user index of the page. Here you will see all the users with their name and email (which upon writing this blog, it has dawned upon me that showing every email associated to this website probably isn’t the best idea). Here you can click a button under the user email that lets you send a “Roommate Request”. Once both parties have accepted the requests, you can add or share lists to each roommate. Without the roommate friendship and list owner approval, no user can view any list other list. So you should feel safe.

Authentication

I will be completely honest here, this section was a pain in the butt. I used Devise for authenticating my users who sign up through my page. Has no problems here. At this point in the curriculum we primarily use Devise for authenticating passwords and great, elaborate and safe sign in features. But then there came Omniauth.

via GIPHY

Omniauth is great. No doubt about that. I’m no security expert, I can’t even imagine the process of trying to encrypt passwords so what better thing to do then let the tech world giants handle security for us. Setting it up alongside of Figaro was where things got really confusing for me.

I will say though, these gems seem to be really praised, they do what they need to do and do it well. With more experimentation, Devise has support for omniauth and can be implemented with a few modifications. Figaro is a gem that hides files from github. Here you can add content like your applications github Key and Secret. Stuff you probably shouldn’t let get into the wrong hands. This remains hidden from github or other users but you can add or modify this all you want.

Features I would like to implement in the future

Originally I wanted to also implement another feature but I thought this might reach the point where javascript will have to be involved. I wanted to implement a “Bill’s” feature or section devoted to the bills that have to be paid by you and the other roommates. Things like repairs around the house, the new washing machine you all decided to buy together or a new 78” curved 4k tv that looks amazing in your living room.

I wanted to implement a page dedicated to the bill alone which displays how much the item costs and a short description or comments associated to this bill. A page that will have info about payments set in stone instead of word of mouth. I also wanted to implement something along the lines of dividing the bill equally between all users, or if I get fancy with it, have some type of functionality that divides it into certain percentages. EX: This person pays 50% while the other 50% is divided between 3 other people. But this will be modified by the person who created the Bill Instance. To go alongside of the bill, I wanted to implement a calendar that shows all the bills related to the user whose viewing them(More elaborate associations). But due to not wanting to spend a bunch more time trying to figure all this stuff out, this will be a feature that will be implemented on a later date.

Conclusion

Overall I’m happy with this project, at least for as far as I’ve gotten it to. It’s a simple project on the front with some complexity in the back as usual. I mentioned earlier how I’m happy with this project and with where I’m at now. It’s mainly due to how I finally feel like I’m at a point where I can see how other things are made. I have an idea of how certain websites function or how this application is run and with enough time and experimentation I feel like I can build a slightly downgraded version of something. But I have more of an idea of how things CAN be done. And even though I have a TON more to learn, I finally feel like I’m in the loop.

I come from a video background so I can better explain it from a video perspective. It’s like watching a movie before post production knowledge vs after working in that field. Before I used to watch movies just immersed in story. I enjoyed certain CGI but I had a very brief or narrow opinion or appreciation for it. Now after a strong interest in Visual Effects and briefly working on things of that nature I appreciate it SO MUCH MORE. Now watching movies is basically like a game of trying to figure out how certain shots were done, what part of this scene was actually built in real life and what was made by a computer(which is a lot more than you may think), appreciating how amazing and seamless and flatout lifelike CGI in film is now a days (ex machina). Now I can tell if this was shot on a phone, what type of movement the camera was doing , what type of camera, what is actually real on the screen. Being able to analyze why a certain object doesn’t work well if it’s due to lighting or a less than lifelike motion that doesn’t fit well.. I listen to sound effects SOOO much more, which is incredibly underappreciated but if you don’t notice it, that means they did a great job. But if you ever want to appreciate a running joke in films that has been going on since 1951 and found even in films like Batman V Superman, Cars, The 5th Element and Toy Story, look into ‘The Wilhelm Scream’.

But back to what I was saying. I finally feel like I’m part of the loop.I I feel like I’ve accomplished something in this field no matter how small my project may be. I’m excited and looking forward to everything else that’s in store in this curriculum. Thank you for reading my blog.