Hacker News new | past | comments | ask | show | jobs | submit login
Learning to Code: Lessons from building a simple Rails app with Treehouse (jasonshen.com)
84 points by jasonshen on Feb 5, 2013 | hide | past | favorite | 37 comments



If you check out the Devise documentation, you'll notice it recommends hand-rolling your own authentication first. This is, IMO, a wise approach - especially if you plan to eventually deploy an app in the wild.

To piggyback on that, I personally think Rails is a poor intro to programming - even web development. What it provides in terms of early results is often at the cost of understanding what it does and why.


I agree with much you say here - I have personally seen too many beginners jump to use Devise, Cancan etc (every app has to have authentication and authorization, right?) without first understanding the core of Rails, and it just adds unnecessary abstraction to what's already a heavy framework.

When we teach (we run an online web development bootcamp), we teach folks Ruby first, then the general web concepts (HTTP, HTML, etc), then lay the foundation of dynamic web programming (rendering templates, routing, etc) with Sinatra, before finally tackling Rails. When we do teach Rails, we stay very close to the framework itself and ask students to build things like authentication from scratch. After they get the core of Rails under their belt, that's when the fun really starts - we introduce comprehensive testing materials, advanced Rails topics, service integrations, complex application workflow, git/github based team collaboration and production app deployment and maintenance concerns.

It takes a while to build up all this from the ground up - but we found this being very effective in pushing people to an intermediate level and build up confidence along the way.


I second that. To deploy a website you'll have to learn Rspec, Capybara, gem, bundler... all Rails idiosyncrasies. In this respect, I found Udacity CS253 far more useful than Treehouse. It's Python based and the course uses a light framework - webapp2 (plus, you don't get lame jokes and it's free.)


How about Flask+Flask+sqlite as an intro to (web)programming? It shows you much more of what's going on in the database backend. Plus, Flask is so small you can still look at it's program code in an afternoon and understand what it's doing.


Hey doktrin - thanks for sharing your perspective! I did see that notice on Devise's documentation. I think Hartl's Rails Tutorial will go through a more basic user auth process.

If you think Rails is a poor first choice - what's your recommended language and why?


>If you think Rails is a poor first choice - what's your recommended language and why?

At the risk of being a little pedantic, I think Ruby is a great choice (Rails being a web framework). Sinatra is much more lightweight Ruby framework that I personally think is more appropriate when starting out. It offers far fewer abstractions (or, "magic") and is a radically simpler beast. To put some numbers on that assertion, the codebase itself is less than 1/100th the size of Rails.

If working with a different language, I recommend starting with some similar level of abstraction. Sinatra-esque frameworks typically offer enough functionality to make development fun while not obfuscating too much of the logic. Spark (Java) is Sinatra inspired. While I've never seriously developed in Python, web.py has been on my to-use list for quite some time.


No worries - you're right, I should have said framework. Will look into Sinatra!


Hey Jason, I'm a learner just like you and have only been working with Ruby for about 8 months. I'm a Treehouse customer and mix those video courses with Codecademy for reinforcement.

I started trying to learn Rails at the same time that I was learning Ruby. That was a bad choice and I gave up after a couple months. When I started back at it recently, I dove straight into Ruby alone and left the frameworks out of it. After I felt comfortable enough in Ruby, I added Sinatra and love it.

Rails is powerful, but Sinatra is "just enough" for beginners like us.


Learn something that requires you to write all the code as your first language (like PHP without a framework), and then Rails as your second "language". Only after writing SQL do you truly realize the power of Active Record, or write session-based authentication do you appreciate Devise. I love Rails's "magic", but I like that I can visualize what a Gem is doing based on how similar functionality would be implemented in PHP or ColdFusion.


I don't understand this point of view. Isn't that the type of thing a new dev is very likely to get wrong and get burned by?

Not that integrating Devise when you're new to Rails is all that much fun either.


    > Isn't that the type of thing a new dev is very likely 
    > to get wrong and get burned by?
I doubt it.

Hand-rolling your own authentication is trivial in Rails. There are plenty of good tutorials and blog posts about it. There's even a Railscast on it. Rails even has a secure password helper and a digest generator.

You're more likely to get burned by Devise when you want to make trivial customizations to it. You quickly get weird override methods in your User model and rigid behavior from code you can't grep.

I think rolling your own authentication is far more newb-friendly. You're only a handful of lines away from your own `current_user` helper, and you retain full control.


To my thinking, auth is hard and the complexities shouldn't be glossed over. And you don't want to bog a newbie down by making them understand what rainbow tables and replay attacks are. So it's better to skip that and circle back around later once they get some familiarity with web dev in general.


I have had a very similar experience to Jason learning Ruby on Rails through Team Treehouse.

I was sick of just being the Hustler for my startups, I raised seed rounds, but could not get my hands dirty in code. Why I No Get My Act Together?!?!?

I have tried to teach myself to code since 2007. I started my first profitable web company at age 20 without being able to afford a computer, but had to pay someone to code it up for me. Why I No Get My Act Together?!?!?

I know that I am not a lead developer or even close, but I am learning the fundamentals and am able to build my own prototypes without bugging someone to be my co-founder. Now I can show them even if the prototype is sh*tty (read: less then great).

I am now going through the Rails Tutorial by Michael Hartl: http://ruby.railstutorial.org/ after going through: https://teamtreehouse.com/subscribe/plans?referrer=jameshigh... and have even played around with changing my terminal: http://net.tutsplus.com/tutorials/tools-and-tips/how-to-cust... played with heroku, github, html, css, js....

I can't wait to go through more: http://programming-motherfucker.com/ as well as learn python and django.

So right with you Jason, more non-tech guys should get their act together and put in the time.


Go go gadget self-described hustler, url-shortening only the referral link in your post. Url shorteners are not healthy for the web and are pointless on hacker news. Referrals are fine, just be up-front instead of hiding behind a url shortener.

goo.gl/0BUvL -> https://teamtreehouse.com/subscribe/plans?referrer=jameshigh...


Thanks for pointing this out, it has been changed back.

EDIT: My inner hustler was trying to get out, I put him back in his cage where he belongs.


Congrats on deploying your app Jason!

All of the lessons learned in your article are really good ones, particularly about reading documentation, and even copying code at first. It's something we struggle with at Treehouse, we want our courses to be as smooth and error free as possible, but it's a bit disingenuous to portray building an app as something so smooth.

Developers encounter errors, Google error messages, and dig through docs all the time. We're trying to integrate some of the bugs we encounter into the videos, to hopefully shed some insight onto how to troubleshoot when errors inevitably occur.


Thanks Jim! I loved having you as a teacher. One suggestion: can you make cheat sheets for all the code we write in each module? Would be nice to be able to recreate the app from scratch without watching all the videos.


What a great idea! Thanks!


One note about copying code:

You'll learn syntax much faster if you hand re-type instead of copy pasting code.


I have been writing code for only about 18 months now and re-typing ~85% of what I see has been incredibly helpful to me. I couldn't agree more with this point.


Seconded. I've been programming for over a decade and this is still how I learn new languages/frameworks.


Totally agree! I did mention "copying and pasting code" but really I only did that with specific bugs where I'd grab snippets of code to fix my problem.

Most of my coding was typed in by hand. I would have to pause the treehouse video, type in the code myself, and then continue the video. Sometimes this would result in my missing a comma or colon somewhere, but I agree that typing it feels like a better approach.


Congrats, Jason! Looks great.

The thing about Rails, for me at least, is that there's so much to it and it covers so many different bases that it's really tough to "learn it." For me, it's been a matter of two years of starting projects, throwing them out, and starting them again to get where I am - a fairly confident Rails programmer. I was also fortunate enough to get to work with a rails app for two summers [0] where my coworkers helped me a ton.

But guides? I don't know, they never really worked for me. It was the hands-on that I really needed, and it looks like your project with Treehouse is exactly that.

I'm still looking for the hands-on stuff [1] (shameless plug) to grow as a developer, since as a student I only have so much time for side projects. I've found that teaching Rails to others - I recently started an Open Source Society at my school - also helps immensely.

[0]: http://www.evidon.com

[1]: http://jordanscales.com/resume.pdf


Hey Jordan - thanks for sharing your journey! I realize this is the first step in a long journey and this post is for those people on the other side of the fence, who may be anxious about even getting started.

Yes, I agree that nothing beats hands on work! Love the hustle.


Quoting Steve Klabink: “Starting Rails today is like starting to watch a soap opera in the 7th season.” http://words.steveklabnik.com/rails-has-two-default-stacks


From the first chapter of Railstutorial : Ruby , gems, rails, git. Bundler, MVC ... Git Branch,Edit, Commit, Merge, Push. Heroku ... Some of them aren't easy or intuitive concepts, you need to work really hard. I think rails isn't beginner friendly anymore, but that isn't entirely bad.


While this is an interesting case (having done the Treehouse tutorial myself), I've got to say that you can't beat Michael Hartl's book for a decent intro to working with Rails.


I disagree.

It's good to read bits and pieces here and there, but he deviates too much into Git, Github, Heroku, Unit Testing, etc.

I want to learn Rails and Ruby. An already hard enough task.

There's no reason to smash my face into so many new concepts at once.

-Source: Myself when I starting out with Rails.

A much better source I found is the book Agile Web Development with Rails from Pragmatic Programmer Bookshelf:

http://pragprog.com/book/rails4/agile-web-development-with-r...

Starts with dumb, .html.erb files, for static HTML, then slowly builds up on previous lessons - WITHOUT GOING TOO MUCH OFF TANGENT.

Unit tests, rspec! the second coming! yada yada. I wanted to learn Rails, most newbie want that as well.


Hey sergiotapia, thanks for sharing your thoughts! What did you think about the top review on Amazon to this book? http://www.amazon.com/Agile-Development-Rails-Pragmatic-Prog...

One must work hard to grasp what is being taught. It requires a lot of motivation, reviewing and double checking. Too much is given at once, in the wrong order and with little explanation (if any). Too much is left open. Proper subject matter review for a consistent explanation isn't available.There is a summary at the end of each chapter, but it is as a statement of goals "achieved" and not an explanation. I could list many examples. One can easily get lost following (or trying to follow...) the book. It can be a real pain.


As a rails newbie I found the integration of all the tools I use, git with remotely tracked branches, unit testing, deploying to a production server, etc to be a refreshing reprieve from sites that give you the basics of one thing and one thing only and no clue how to put them together with the other aspects of my job. The ramp up on Hartl rails tutorial was perfectly paced in my opinion.


The Hartl tutorial does start with static pages (in fact I believe that's actually the name of Chapter 3), but fair play - I hear good things about the Prag Prog book too.


While they're far from comprehensive, I've found the tutorial approach at CodeSchool.com to be well worth the $. (With the basic Rub, Rails, and Git tutorials being free)


I've done Hartl, as well as several Code School courses and a couple other tutorials, yet I still don't feel confident enough in my skills or knowledge to begin my own project or contribute to an open source one. I feel like something is missing from these education sites.


The part that's missing is the part where you start your own projects so that you have something to apply the knowledge to. Else you're just reading about surfing and wondering why you don't feel ready to surf yet. Maybe just one more surfing book?

You don't need confidence because your projects don't need to leave localhost. Most don't no matter how experienced you are. They're for your own education.

I have 102 projects in my Code/ directory. I have only 5 repositories on Github.


I wonder how new devs feel about learning Rails now that yaml has been discovered to be a serious attack vector, and will possibly (probably) be a source of many security concerns in the future.


I feel much better now. Rails enjoyed that near invincible status long enough and the other shoe was bound to drop sooner rather than later. Now that we've got this out of the way, as well as the mass assignment issue of last year, maintainers will hopefully take POCs and disclosures more seriously in the future.


Depends on whether or not they understand what it does.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: