Our first assignment as new interns was to make Blog Posts that were published visible to everyone at the website, and the Blog Posts that were not published visible only to logged in users. After some research we figured out that we will do that by setting up scopes at the Blog Posts model and then change the index method in blog controller by assigning new variables.
Then we had to test it using both rspec and capybara gems. Couple of problems occured along the way, but with knowledge from reading gem documentation and with help from more experienced colleagues we were able to make tests pass.
Next task we got was to create new feature - topics. The idea was to separate blog posts and assing each of them to corresponding topics either while making new posts or by editing those that were written before. To make this happen we had to make a new controller, model and view (based on blog posts) for admin mode. Then we had to generate migrations for new topics table, and also for adding a new column to blog posts (to see the connection between those two). First, and the biggest problem was caused by naming all new content "Threads" which turns out to be reserved by Rails. Because of that, we saw all sorts of errors, so when we figured out that it was the source the problem we had to start from the scratch, and name all files "Topics". In order to make everything work the way we wanted, the most important thing was to connect blog post and topic models by belongs_to and has_many.
Finally, topics tab was completed, logged in user could see how many and which posts are included in seperate topics. Another assignment was to enable filtering blogposts by topics, and by "published" value. We decided to do achieve that using simple form gem:
By using this form, we choose topic from collection of topics (or we select empty space which stands for all of the topics and it's indicated by allow_blank), and choose radio button for "published" or not. By clicking submit we send params to the controller, where results are being stored by corresponding variables, which brings us to the final version of index action.
Finally, I would like to share couple of free sources that I'm learning rails from, for all of You that are just starting out, like I did 2 weeks ago :)
Getting started with Rails