Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Validating Length

Sølvi Qorda
Sølvi Qorda
14,194 Points

Way out of my depth...

I was really looking forward to this course, having completed the preceding units in the track and understanding 95% of it, and chomping at the bit to actually BUILD things.

But this just seems like a huge jump, with only ruby basics as a foundation.

I'm thinking of just going through the Ruby course, because all of this Rails syntax is just being thrown in with little to no explanation, and I'm just going through the documentation on every method call because it seems like such a huge step up from Ruby basics. I understand the console and git work but everything about Rails is just coming in like a swarm of TIEs and I'm here sitting in my rusty Y-Wing, realising I should have saved up for a newer model...

Is anyone else having this sensation or am I just pranging out unnecessarily because I'm being unrealistic about my expectations?

noah finnerman
noah finnerman
15,380 Points

I hear you, it's a big jump!

9 Answers

Solvi, I understand your pain. If you have a reasonable understanding of Ruby, I think you're at the hardest stage of your development, and this is where Treehouse starts to let you down a bit. You're probably used to following the Ruby courses and it's been well-structured with a clearly defined path? And now you're trying to make that connection between Ruby and 'how you get that on a webpage'.

I've been there, and I need to have a bit of a think about what to point you towards, actually. At this stage, it's crucial that you get a firm grasp of the relationship between your Ruby code and how it fits together with a server and other things to end up with web pages that do stuff.

I wonder if there's a good Sinatra tutorial out there?

The best thing you can do next is not to go straight to Rails, but to write something in pure Ruby and then serve it to a browser using Sinatra. The end result would be something like this: https://github.com/Yorkshireman/rps-challenge

Play it online using the link, then have a look around the files in the lib folder; they should look familiar to you, which should give you some encouragement. It was written in pure Ruby first - game results just being printed to the console instead. Then it was hooked up to the browser with Sinatra (Sinatra is like a much lighter-weight, simpler Rails) and deployed to Heroku to have it running online.

It's making that leap between your pure Ruby and your browser which probably feels completely perplexing right now. Have a look around and see if you can find a tutorial that haves you write something in pure Ruby and then hooks it up with Sinatra. I can't give you the tutorials I used because they are part of a coding bootcamp I attended. But it really is worth getting your head around this before jumping into Rails. Trust me on this, I've been there. Tomorrow I might have a little look around for you.

What challenges in particular are you facing? What are your concerns?

Out of the Treehouse courses, once you've got a good grasp of pure Ruby (don't worry about Procs and Lambdas though), this is the best next step: https://teamtreehouse.com/library/build-an-address-book-in-ruby

You MUST learn TDD..... NOW. I can't stress this enough. I didn't, then learned Rails. And because of the big hole in my knowledge, I ended up going to a coding bootcamp and that sorted me out with TDD and SOLID (google "SOLID") principles. That is what gets you a job.

This book would have been perfect, but this page says it's out of print - but maybe you can find a pdf download or a 2nd hand paperback on amazon or ebay? https://pragprog.com/book/achbd/the-rspec-book

That book would be perfect for you right now.

Treehouse barely mentions TDD, and that's because it's slower AT FIRST, so less instant gratification which leads to more subscriptions.

Trouble is, if you want to get a job, you MUST MUST MUST code using TDD. So you have to learn it now, before you get too used to not learning it.

Read the README on that repo I sent you and clone it and run the tests, then look at the test files.

Hi Salvi (and everyone else struggling with this),

This isn't just Ruby, it's an entire framework based off of MVC model - or model version controller. Rails allow you to design and deploy a web app pretty quickly because of the structured framework. It's not something you would grasp right off the basics Ruby course. It's something that had to be explained to me. So, just a quick intro, MVC creates a delegation of responsibilities for the data that is requested, stored, and displayed. V in the MVC, is what you are a viewer sees on the webpage. C, is the controller that accepts the request for a certain information, and passes it on to the M or Model (the brains behind this, and the one that talks to the database). So, if you can imagine, say, you go to amazon, and want to view a certain item. You type in a request, the Controller, as a quarterback, either, returns another page for you to view, or asks Model (the working horse), to grab the item from its database, and then returns it back to the Controller. The controller, then returns this to the View to display it to you. That Jason is starting with TDD, test, to drive the development of his code is the accepted way of coding. Where you write the test, make it fail, then write the minimum amount of code to make the test pass. When you refactor, or redesign things, you run the test again, and make sure that the functionality (which what testing helps you ensure) stays intact, despite the code rewrites.

I hope that helps a bit. I am sending you a link to two things. It's an exercise on how testing can help you write code. Below is a github link to an exercise called mythical creatures. it's a fun exercise. the tests are mostly all written out, and you have to unskip each test and make it pass. and then you will see a whole class come together. I'd strongly suggest you read the readme file, and go by the suggested order, as it gets incrementally harder, and you are required to start writing your own tests eventually. the vimeo shows a demo of three of the hardest one.

most of the tests for these exercises were written by famous katrina owens. she is creator of exercism.io. again, you can go there and do a ton of tdd exercises. i learned a lot going through them.

https://github.com/turingschool/ruby-exercises/tree/master/mythical-creatures https://vimeo.com/129974441

James Joyce
James Joyce
3,551 Points

Great reply Piper. Thank you for the info. Taking a step back and reviewing the MVC architecture is really helpful. This is a good video that explains the MVC Architecture:

https://youtu.be/3mQjtk2YDkM

This page explains the different directories in a Ruby on Rails app.

http://www.tutorialspoint.com/ruby-on-rails/rails-directory-structure.htm

I found a youtube tutorial to build a movie review app that I found a little easier to follow, and I wasn't running into the deprecation problems that are making the treehouse Ruby on Rails videos difficult to follow.

https://youtu.be/0DR5JLZ2Qgg

James Joyce
James Joyce
3,551 Points

Hi Solvi,

I was also experiencing the same lost feeling. Instead of pausing on the ruby on rails track and diving into the Ruby courses, I took a step back altogether and tried to get an understanding of all Ruby syntax. This is a really good resource:

https://www.codecademy.com/articles/glossary-ruby

I wrote out each concept on an index card with an example. If one concept or example did not make sense from that glossary, I googled just that particular piece of ruby syntax.

Segmenting it like this allowed me to focus on one concept at a time, and now I have those syntax index cards to reference when I get lost.

I do think Treehouse should consider re-shooting this series because the portion about writing tests is too fast paced in comparison to the previous videos in the ruby on rails track (those videos are phenomenal). Starting at writing ruby tests, I feel like concepts are breezed over that were never discussed (or not covered in enough detail).

Things that I think would make this video better:

-Start off by building the todo_list app, then get into testing later in the series

-Writing code comments on each individual test to explain what that test is doing

-Explaining the syntax used in each test as it is being typed (why it is used, and what it is doing)

-Going slower when typing out code, and copying/pasting code to other parts of document. I found myself constantly pausing the video and having to backup the video several times to see exactly which parts of the code were copied, where exactly to paste them, and what portion of that code to edit.

I hope that helps Solvi

Sølvi Qorda
Sølvi Qorda
14,194 Points

Wow, thank you Andrew this is a phenomenal response. I think you're right - I need to build up my ability to write pure Ruby - do running without learning to walk.

So, just to clarify, is TDD Ruby 'off' Rails?

TDD is 'test driven development' and you can do it without Rails. You can do it with pure Ruby. Maybe I'll write a tiny example for this and post it here, just to demonstrate.

Have you got a development environment setup on your own PC or MAC? i.e. Mac OSX or Linux?

Ok, install rspec (gem install rspec) and then make a folder and initialize rspec inside it (rspec --init). Initialize a git repo inside it and push it up to github. Let me know when you've done all that and I'll run you through a VERY basic piece of TDD.

Brad Chellingworth
Brad Chellingworth
11,542 Points

I am in agreement, it does seem to be a big leap. I don't think its the content, more so the speed that new content is served versus how slow everything else is. Then there is no real explanation. I feel like all im doing here is pausing the video and copying text. I'm not really learning.

I understand the importance of TDD and I have the basic concepts of Ruby and OOP. I just feel this stage is not being explained. This is our first look at rails and it feels like we are doing the end project without actually learning it.

Brad, I recommend building a simple "Hello World!" app in Sinatra i.e. just a Sinatra app that has one view with 'Hello World!' on the screen.

After that I would build a simple CRUD app in Sinatra: something like a good old ToDo List. Maybe do a Rock/Paper/Scissors app. Deploy all these things to Heroku, too. If you can do these things using TDD too you're well on your way to your first coding job.

Ah, as an addendum to the above. I forgot to mention one thing: the exercisms.io and the mythical creature exercises use Minitest, instead of RSpec. I've been using both, but much prefer the Minitest suite (ruby comes prepackaged with it, so you needn't make additional installment), as it gives you a tally of how many assertions you make, in additional to the example questions.

Lastly, there is another gem called MRspec, and that gives you the best of both worlds. It's a Minitest and RSpec mashup. The only thing is that you have to be on your root branch to test instead of your test branch.

James Joyce. There are a few resources out there that are benchmarks of learning rails. I think most people learn from Hartl. I've never looked at his book, or the screencast, but they seem to be good based on the reviews i've read. I actually learned rails from following along the online tutorial pragmatic studio, cuz i learned ruby from them too, and i knew them to be good. actually, they are excellent! i'd say their pragmatic studio is really one of the best ways to learn rails. there are reviews of them by professional rails developers who took their course, to help them hone the foundations. it's expensive, but if you want to bank your career on this, you might as well pay to get a good foundation. and that's what the couple that teaches it do, is they really take their time to make sure you understand this. there's always a recap with each episode with diagrams, so it gives you a good picture of why you go to controllers, than to the model, then back to the controller, than to the view. and when a database gets called. also, i found the Activerecords vid taught here to be good too. you can't quite understand how to query database, and use rails effectively without knowing how to use Activerecords. i had to build Activerecords-like program, with tdd, from scratch, and it took me 2 weeks, and knowing that there's a program that rails uses with a single method like .order or .where, to search your database and that this takes place in the model of MVC really helps you understand how to customize your applications. good luck!

James Joyce
James Joyce
3,551 Points

Hi Piper,

Thank you for the reply. I'll definitely check out the ruby on rails course from pragmatic studio. Thank you for the suggestion.

-Jim

Folks, this is turning out to be a popular thread, and quite rightly so, I think; it represents a common Blocker in people's development - making that jump from pure Ruby to a framework.

I'm a professional Junior Developer now (mostly Ruby) and I still standby the 'Best Answer' I wrote a few months ago. It's crucial to build something very simple with Sinatra, preferably TDD with Rspec & Capybara. I recommend:

  1. Make a Sinatra app that has one page with "Hello World!" displayed (yes, really). Deploy it to Heroku.
  2. Make a ToDo List app using Sinatra. Deploy it to Heroku.
  3. Make a Rock/Paper/Scissors app that runs on the command line. Then use that code to make a Sinatra app that lets you play it in the browser. Deploy it to Heroku.
  4. Make a ToDo List app using Sinatra and a postgres database and Datamapper.

The above won't be easy for you, but that's the point. The last two tasks, particularly, will represent a huge shift in your understanding, and if you manage to do them, especially if you've done them using TDD, you will be on the road to becoming professional.

I don't have so much time these days, but I hope Treehouse keeps giving me the Moderator status so I can contribute occasionally. Anyone is free to link up with me on Github or talk to me privately using the links through my profile.