The Intro to Rails Screencast I Wish I Had
videos

The Intro to Rails Screencast I Wish I Had

Tutorial Details
  • Subject: Ruby on Rails
  • Difficulty: Beginner
  • Format: 40 Minute Screencast

Isn’t it funny how most “introduction to Ruby on Rails” screencasts are overly simplistic, and rely on generators like scaffolding? The teacher typically follows up the tutorial by stating that most Rails developer don’t use scaffolding generators. Well that’s not much help then! I’d like to give you the tutorial I wish I had. Along the way, we’ll also rely heavily on test-driven development to build a simple app.

Choose HD for the clearest picture.

Covered in this Screencast…

  • Create models and generators
  • Use test-driven development to plan and test an application’s features
  • Work with ActiveRecord
  • Autotest with Guard
  • Use Rspec and Capybara to simulate the user.
  • Create partials
  • Take advantage of Flash notices
  • …and plenty more

Conclusion

If you watched the entire screencast, I hope you enjoyed it! There’s certainly much more to cover, but we crammed a great deal into thirty minutes or so! What other tricks and techniques have you picked up, if you’re just digging into Rails?

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Ditto R K Asnar

    Hi, I’m a newbie to rails,

    I keep getting this error in guard
    ActiveRecord::StatementInvalid:
    Could not find table ‘tasks’

    But when I check rails console, it displays just fine when I type Task.all

    • http://www.estebanf.com Esteban

      I´m stucked with the same problem too. Did you find a solution?

    • http://www.codemonkeydev.com Thomas Cannon

      I’m running into the same issue, I’m pretty sure I have all of the code typed in correctly, and my DB has been created (I tested with the Ruby Console). However, I can’t get guard to reflect the changes.

    • http://michele-garoche.org/ Michèle Garoche

      Actually, when you run db:migrate it runs by default in the rails development environment, that is on the development database, not on the test database, which guard uses when running the tests.
      So to correct this you have to run the migration in the test environment (and eventually prior to that, create the test database the same way, that is with RAILS_ENV – see above):

      rake db:migrate RAILS_ENV=test

    • John

      rake db:test:prepare

    • http://rymai.com Rémy Coutable

      As mentioned in the Ruby On Rails Guides: http://guides.rubyonrails.org/testing.html#preparing-your-application-for-testing

      you should run:
      $ rake db:migrate

      to runs any pending migrations on the development environment and updates db/schema.rb.

      An then run:
      $ rake db:test:load

      to recreate the test database from the current db/schema.rb, or rake db:test:prepare (it first checks for pending migrations and warns you appropriately).

      Hope that helps!

    • http://www.mikegraf.ca MaerF0x0

      I had this issue

      Failures:

      1) Tasks GET /tasks display some tasks
      Failure/Error: page.should have_content ‘go to bed’
      expected there to be content “go to bed” in “Tasks\n\nTasks#index\nFind me in app/views/tasks/index.html.erb\n\n\n”
      # ./spec/requests/tasks_spec.rb:8:in `block (3 levels) in ‘

      I ran

      rake db:test:prepare

  • http://cell-designs.com Marcell Purham

    very good rails tutorial. This will help my development skills tremulously

  • Konstantin

    Thanks, that happens to be exactly the kind of rails intro I always wished I had. For the first time now I get what that rails for zombies course tried to teach me

  • aa

    Great tutorial but still a little complex for newbie like myself. I know basic Ruby and read couple of books on rails 3, although this does not use scaffolding which is great, but still being a newbie i also don’t want to complicate with running tests etc, but just appreciate a simple version without testing, scaffolding etc and some more info about what’s being typed in controller and view files.

    I am totally disappointed at any way to move forward from basic rails knowledge to next level, as every other tutorial is asking to setup testing, git, or use scaffolding, whereas why do i have to complicate my learning with all those parts at this beginning stage.

  • Ernest

    Hmm anyone having problem with your tasks_path being a undefined method? I couldn’t seem to get that to work properly. I ended up using

    visit ‘/tasks’

    instead of

    visit tasks_path

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      What do you get back when you run rake routes in the Terminal?

      • http://www.techsoftsolutions.net Samuel

        rake routes help you to get all the possible routes that defined in your config/routes.rb file. Kindly note if you are using other gems that define hidden routes like devise and the authlogic, you can get inbuilt routes from the gems.
        Thanks

  • Chris

    I keep getting ‘guard’ is not recognized as an internal or external command, operable program or batch file.

    • Ryan

      I found that using the command ‘bundle exec guard init rspec’ worked. Hopefully it will work for you too,

      • Terry

        Thank you this worked for me!

  • nija

    what is the solution of this event?

  • http://www.mauromarano.it Mauro

    Hi, very nice tutorial.

    Can you explain me how to use the comand subl from the terminal to open the files in sublime text 2?

  • Alex

    This video really got me going. I love the pace. Although I’m new to rails, I come from CakePHP and it seems to make a lot of sense. Jumpin in this weekend for sure.

    Thank you.

    From
    $this->set(‘variable’, $this->Model->find(‘all’));

    To
    @variable = Model.all

    Awesome.

  • http://www.rockhopperdigital.com Benjamin Zalasky

    Anyone else failing the last test? Delete appears to work when I test it manually in the browser, however, I’m getting this error when I run Guard.

    Nokogiri::CSS::SyntaxError:
    unexpected ‘#’

    With regard to this line in tasks_spec.rb:

    find(‘#task_#{@task.id}’).click_link ‘Delete’

    • http://avanslaars.tumblr.com Andrew Van Slaars

      I’m having the same problem. Did you find a solution? I just ran into this late last night and haven’t had much time to experiment to find a work around.

      • http://www.rockhopperdigital.com Benjamin Zalasky

        Never figured it out, but the code all seems to be working. So, while it’s annoying to have an error, I’m chalking it up to some configuration quirk unless someone tells me otherwise.

    • http://www.castamic.com Jorge I. Castañeda

      i know why it doesn’t work!

      you are putting:

      find(‘#task_#{@task.id}’).click_link ‘Delete’

      instead of:

      find(“#task_#{@task.id}”).click_link ‘Delete’

      • http://www.rockhopperdigital.com Benjamin Zalasky

        Sweet! I’ll give that a try. Glad that it was something as simple as that…

      • govnah

        thanks for the solution, it helped me out a lot…

        i just had to changed it to:

        find(“#task_#{@task.id}”).click_link “Delete”

        the Delete should be double quotes like so => “Delete”

        thans

  • Daniel

    I’m not sure if this is a windows error, or an error unique to me but Jeffrey certainly didn’t seem to need to do this.

    Anyhow. If any of you are having problems getting past 4 minutes 11 in when you have to run ‘rails g’ with an error about minitest, first install the gem minitest then go back to the Gemfile that was open earlier, and add ‘gem ‘minitest’ ‘ to the group.

    After that you should have no problems. If this was only happening to me, it’s possible that it’s because I only recently put ruby on my system. Anyway happy coding and great video Jeff!

    • http://rorywalker.com Rory Walker

      Hi Daniel,

      In your GemFile, use this

      gem ‘turn’, ‘< 0.8.3'

      • http://www.wearecondiment.com Chris

        Thanks Rory, that worked for me. Anyone care to explain what this does, though?

        Thanks!

  • http://ww.rezzz.com Jason

    First off, great job!! Totally been what I’m looking for. So tired of the “let’s use scaffold, but no one uses it” tutorials.

    Now, I went through your tutorial and got to the point where I’m just running the test on the index action of the controller. With only 3 tests and no failures, I’m coming up with 8 seconds in total time. Seems pretty slow to me, considering I’m seeing your tests run in well under 1 second. I’m running OSX Lion and Rails 3.1.3, Rspec 2, Ruby 1.9.2 — just created the app today as well.

    I would appreciate any thoughts you have on the matter as I’m afraid as I build on top of this, it will be tremendously and painfully slow because of this foundation that doesn’t have much involved and taking a long time.

    Thanks again in advance!!!

    • http://www.rezzz.com Jason

      I took out require ‘spec_helper’ from the top of my integration test and it came in under the 1 second like it should be, but I noticed that you have that line in there. So I’m not sure if that’s really the culprit. I’m thinking that I don’t need to include that unless I really “need” it.

      I’d appreciate any thoughts.

      • http://www.rezzz.com Jason

        Nevermind that last comment – I now know that was wrong now. Still getting 8 seconds on my base 3 examples. No idea why

    • http://www.rockhopperdigital.com Benjamin Zalasky

      What are the specs on your system? It could just be a performance issue.

      • http://www.rezzz.com Jason

        It was the load time. My system would take a little while to load, but once loaded it was quick. As I added tests, it only increased the time in increments that it should’ve.

    • Andrew Stewart

      I’m having similar performance issues with Guard-RSpec, running an identical setup.

  • Albert

    I’m having some issues getting ‘guard init rspec’ to work – i have Guard (0.9.3) and Guard-rspec (0.5.10) installed, but i keep getting the “guard is not recognized as an internal or external command…”

    Around 4:30 in the tutorial.

    Thanks in advance!

    -Albert

    • Albert

      Turns out I just had a typo…silly me!

  • Brian Frichette

    This is the most awesome tutorial I have EVER watched. Great pace, all the junk edited out, and the content was enough to make me fall in love with Rails having never written a line of Ruby code.

    Thank you so much!

  • Darragh Flynn

    Just having some issues with guard init rspec…the Guardfile is in my root directory. I’ve tried the “Touch Guardfile” solutions within the file but to no avail.

    Mac OSX, Ruby 1.8.7, Rails 3.1.3, Guard 0.10.0, Guard-Rspec 0.6.0.

    Will comment a solution below if I find one >-<

  • Edu

    Not the biggest problem, but I don’t get those colors (red/green) in my command line. I have the ‘win32console’ gem installed and referenced in my Gemfile. I am running windows 7. Has anyone had, or more importantly, solved this problem?

  • Thomas Bush

    thomasbush cms$ guard
    WARNING: You are using Guard outside of Bundler, this is dangerous and could not work. Using `bundle exec guard` is safer.
    /Users/thomasbush/.rvm/gems/ruby-1.9.2-p290/gems/rb-appscript-0.6.1/lib/appscript.rb:542:in `_send_command’: CommandError (Appscript::CommandError)
    OSERROR: -10000
    MESSAGE: Apple event handler failed.
    COMMAND: app(“/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app”).register({:all_notifications=>["success", "pending", "failed", "notify"], :as_application=>”Guard”, :default_notifications=>”notify”})
    from /Users/thomasbush/.rvm/gems/ruby-1.9.2-p290/gems/rb-appscript-0.6.1/lib/appscript.rb:642:in `method_missing’

    …….followed by 18 more similar lines

    I am having issues with guard init, I have looked at stackoverflow for a solution, but the answered solutions there would not work. I tried running ‘bundle exec guard’. Please help, I am new so I know I have done something dumb here. Any advice you could give to help me correct this issue would be appreciated

    • Thomas Bush

      Alright I fixed it!

      Here are the steps I took:
      – update growl to 1.3.3 – dowloaded from the app store.
      – replace the “growl_notify” gem with “ruby_gntp” gem in your Gemfile.

      Through lots of reading I think I had incompatible versions and this corrected my problems. Sorry if that error was an obvious and/or dumb question, this is my first ruby app, but its fixed. Just figured I would post results to help any one else with similar issues.

      • Yosuke

        Thomas,

        Thanks a lot! I had exactly the same problem, and your solution solved it instantly. I really appreciate it.

        Yosuke

      • Yosuke

        Thomas,

        Thanks a lot! I had exactly the same problem, and your solution solved it instantly. I really appreciate it.

        Yosuke

      • Yosuke

        Thomas,

        I had exactly the same problem, and your solution solved it instantly! Thanks a lot for your work.

        Yosuke

  • Christoph Rumpel

    Hi,

    thx for the screencast. As many others already mentioned it is too fast. I was going through your session “The Best Way To Learn Ruby” and this screencast was right after “tryruby”. Feels like a lot of videos were missing between those tuts. It was creating more questions than giving answers. Especially when you have not been working a lot with the terminal.
    greets

  • Daniel van Flymen

    If you are having a problem running rails generator or rails g then open your Gemfile and change the line that says gem ‘turn’ to gem ‘turn’, ‘< 0.8.3', save the file. Run bundle install and then rails g should work.

    This is because minitest is now a dependency.

  • Daniel van Flymen

    If you are having a problem running rails generator or rails g then open your Gemfile and change the line that says gem ‘turn’ to gem ‘turn’, ‘< 0.8.3′, save the file. Run bundle install and then rails g should work.

    This is because minitest is now a dependency.

    • Morgan

      Thank You, that was doing my head in!

  • Rich

    How is any of this stuff an introduction? The screencast immedieately dives into gems, test driven development, etc.

    Seems more of an introduction to the language *for experienced programmers*, no?

    I think these guides promise more than they deliver.

  • Oleg Kostyuk

    Is there possibility to get subtitles for this video?

  • marc

    hey geffry your site is fucked up in safari :D

  • Marc

    just at this site right here : http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/comment-page-2/#comment-403907

    fyi

    @ tutorial: this big focus on the TDD is …not cool

  • Vadim

    Great tutorial, thank you!

    If anyone getting “Can’t mass-assign protected attributes: task” error add this to your task.rb models file
    “attr_accessible :task”

    Something about rails updating their securities..

    • John

      Thanks! I can move on now…

    • Steph H

      Thankyou! This has had me stuck for hours!

  • http://none cbrwizard

    Hey, nice tutorial, but I need a lill’ bit of help here
    After the ~15th minute I am having a trouble – guard shows an error
    “TasksController GET ‘index’ should be successful
    Failute/Error: response.should be_successful
    NameError:
    undefined local variable or method ‘be_success’ for #”

    What should I do? Why did this happen? Thanks

  • Josh

    I’m sure this is a great tutorial on how to use Rails, but you talk as though we can all watch, type and understand what you’re talking about at the speed of light! As soon as I’ve heard what you’ve said, switched to my terminal and typed what you’ve said, you’re already onto something totally different! SLOW DOWN!

    This isn’t an ‘introduction’, it’s an advanced course for coding ninjas.

    • http://imyjimmy.com Jimmy Zhang

      This tutorial def takes a couple days to digest.

    • Captbaritone

      Disagree. With the pause button the pacing is just fine. I would rather pause when I need more time than wait for the slowest member of the “class”.

      • Shiri

        I think the content was covered well as he really dumbed down everything, but he did talk and type EXTREMELY fast.

  • Sebastian

    Nice tutorial..but I still don’t get it :(

  • Stefan

    If you are getting a long error while running guard, try removing the turn gem and re-bundle

    Right now there’s an issue with turn messing up rspec, and turn really isn’t necessary anyways.

  • http://mmhan.net Mike Han

    Phew… Due to rspec’s slow initialization and your fast paced lesson, it took me nearly 3 hours to follow through it with you.

    It certainly has been an adventurous ride. I have a few questions though.

    - Why integration test, instead of MVC-layered test? Coming from CakePHP, I have always been testing each abstraction seperately. Is it mainly because it’s easier to digest for a beginner or is it a common practice for the ROR tests?

    - Although it would have been certainly easy to google for all the gems that were installed along the way, it may be useful for many of us if you had given a passing mention of the purposes of why a gem was required. It’d have been helpful to know why we need certain gems allowing us to adapt what we learnt in other lessons and real projects.

    These points shouldn’t take away any credit from this screencast which is really a great tutorial. As soon as the beginner is done with the scaffolding tutorials, the definite second thing they should be learning is this.

  • Jack

    Great tutorial mate but seriously please slow down haha, you type something then before i get a chance to read it its gone, it makes it a little hard to keep up especially when your new to rails.

    But thanks for a great tutorial its great to have people like you around that help the community

  • http://www.robhuzzey.co.uk Rob Huzzey

    Sorry but this tutorial is too fast an isn’t really an ‘intro’ as it’s too focussed on TDD.

    I would like to see a more paced tutorial and this one as a follow up as the content could be relevant just not so for a Rails beginner like myself.

  • GG

    Every command you tell me to type, I get a message saying it’s uninstalled. I installed rails via rvm – should I change the commands to reflect this?

  • http://imyjimmy.com Jimmy Zhang

    Jeff, awesome stuff. Only ran into one hitch.

    For me, validation worked the following way:

    validates_presence_of :task

    Because when I write it as

    validates :task, presence: true

    I get the following error:
    /Users/imyjimmy/Documents/workspace/tasks/app/models/task.rb:3: syntax error, unexpected tSYMBEG, expecting kDO or ‘{‘ or ‘(‘
    validates :task, presence: true
    ^

    So, I’m not sure how you managed to pull that one off. Maybe we’re on different versions of rail? I dev on OS X Snow Leopard, not Lion.

  • Chris Portela

    In the task.rb model there is a problem with the code shown. If you use the normal way it looks like this

    class Task < ActiveRecord::Base
    attr_accessible :task
    validates :task, presence: true

    But because of some changes in ruby (or so it seems http://stackoverflow.com/questions/10134906/ruby-on-rails-mongoid-validator-not-found)
    You need to use this code

    class Task true

  • Speak Slower

    Can you speak slower please, you sound like you need to get laid.

    • Pavan Katepalli

      lol you’re garbage. How about some appreciation for hard work.

  • Bill Sundry

    I don’t feel like this is the “Tutorial I Wish I Had” at all…

    He blows by concepts like they’re no-brainers, assumes we know a decent amount about Rails before beginning, and has a terrible voice for speaking to a crowd. While I’m sure he’s extremely knowledgeable, I don’t feel like I’m any more comfortable now than I was 45 minutes ago. Rails for Zombies was definitely the way to go for me.

  • Chris

    This tutorial was incredibly good! Thanks!

  • Peter de Ridder

    I really liked this tutorial. However, I would say that the level of this tutorial is more like “intermediate”. It’s nice to actually see someone building an app from scratch without skipping a few steps with scaffolding. This helps in building understanding for beginners. Unfortunately, those same beginners will have a hard time to understand all the concepts you briefly talk about.

    I like fast tutorials, but not when I’m entirely new to the subject. Since I’ve started learning Ruby on Rails a few months ago the pace of this tutorial was perfect for me, but I think newcomers will scratch their head several times, especially when it comes down to testing. They probably have no clue of the syntax and I personally think you should understand some of the basics of Ruby on Rails first before you start testing. It seems hard to me to test something you don’t quite understand.

    Nevertheless, thank you for taking the time to educate us further in Ruby on Rails.

  • Whitney

    wow, just me or did the last 5 minutes run together?

    otherwise, very thorough explanation. thanks!

  • http://jasonseney.com Jason

    While this does graze over a few things( i.e. erb), I honestly do feel its the best intro for experienced web developers coming from other platforms.

    All the other details I can just look up on my own – this is a good way to jump in and learn by example.

    Also, I think the pace was spot on, and about at the speed of other professional programmers I’ve worked with in the past who are explaining things. I usually rage quit tutorials that are really slow or leave time to go get coffee while they type or over explain each concept.

    Well done!

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Thanks, Jason! :)

  • bel3atar

    This is not for beginners.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      It’s for experienced developers coming to Rails for the first time.

  • Omnia

    Anyone else failing the last test ? Delete appears to work when I test it manually in the browser, however, I’m getting this error when I run guard.

    Failure/Error: find(“#task_#{@task.id}”).click_link ‘Delete’
    Capybara::ElementNotFound:
    Unable to find css “#task_1″

    • Luke Greene

      yes, i am getting this. did you ever find out what the problem was?

      • hello, i’m name

        he switches find(‘…’) to find(“….”). i hardly noticed it after an
        hour or so of trying to find out what was wrong. it is on the screen for
        about a second. but the problem is you need to change the single quotes
        to double quotes.

  • ablay

    Video is broken

  • http://tankjetstudios.com Chris Carter

    This is a great tutorial for people that are making the transition from perhaps front end code to back end, or from another language into rails. I’m very thankful that someone took the tike to put this together for free. Once I get a better grasp on the basics I’m planning on releasing a real “Beginners Guide”. In which common sense teaching skills will be applied, no TDD when you don’t understand routes or controller methods.

    A lot of these guys trying to teach have been doing it for years, or are especially quick with picking up syntax, hence being a developer.

    Either way, this was great for me. It taught me a lot of new things, moved fast enough to keep my interest and I will be on my way to building my MVP soon thanks to this tutorial.

    Best

  • rickcuri

    Trying to complete the tutorial but I can’t find what is wrong:

    Guard::RSpec is running, with RSpec 2!
    Running all specs
    F

    Failures:

    1) Tasks GET /tasks display some tasks
    Failure/Error: get tasks_path
    ActionController::RoutingError:
    uninitialized constant TasksController
    # ./spec/requests/tasks_spec.rb:6:in `block (3 levels) in ‘

    Rake routes returns this:

    tasks GET /tasks(.:format) tasks#index
    POST /tasks(.:format) tasks#create
    new_task GET /tasks/new(.:format) tasks#new
    edit_task GET /tasks/:id/edit(.:format) tasks#edit
    task GET /tasks/:id(.:format) tasks#show
    PUT /tasks/:id(.:format) tasks#update
    DELETE /tasks/:id(.:format) tasks#destroy

  • Nathan

    I’m getting really frustrated with learning Rails. No matter what tutorial I follow, I’m lost. I run into an endless, infinite slew of problems when trying to follow their steps, which I then have to Google and spend hours solving each time. The tutorial never addresses any of them and assumes it will all install just fine.

    In this tutorial, I’m following along at the beginning, we add turn, rspec-rails, capybara and guard-rspec to the gemfile in the “task” directory.

    Then type bundle to install them.

    Now it says it can’t continue because I haven’t installed Nokogiri. I have no idea what that is.

    What is Nokogiri?

    Why does rails always ask me to install another gem after gem after gem saying “can’t install this gem until you install that gem”?

    Now it can’t install Nokogiri because of some reason located in a log file I can’t find.

    UGH

    • itos

      Try the Rails Tutorial from Michael Hartl

  • Nathan

    Haha, this is so exasperating it is funny.

    So I finally resolve the Nokogiri thing, and the very next step after the bundle install was to type “rails g”.

    Guess what? Now it says I can’t do that because I’m missing the java runtime.

    This is endless.

  • Nathan

    Now after having fixed that last one after installing nodejs, I get an error with minitest. Yet another Google search solves the problem with changing the gemfile to add ,’< 0.8.3' after gem 'turn'.

    Then rails g again. Guess what? Another problem, this time, it's something else requiring the installation of something else that requires the installation of something else, but there's a problem with that installation which requires fixing so that I can apt-get this thing to install that thing to install the previous thing which allows me to install the original thing to get to the next step which requires me to install another thing which has a prerequisite installation of something else.

    Are you getting my point?

    You know what the screencast I wish I had is? One that takes everyone through all of this nonsense.

  • Suzanne

    This looks great, but the commands are typed in so fast, and it’s difficult to pause while still seeing the command typed…splicing is really tight. Is it possibel to get a list of the commands used in the beginning of the tutorial ? I’m only on minute 5 and it’s taken me about an hour to get this far with troubleshooting new updates to xtools, rbappscript, growl, etc ,etc.

    Downloadable video would be great so I can control the size and the start stop a lot easier!

    Thanks for the work!!