Web Designer Pro Bundle - $500 of Site Templates, Stock Photos, Code, Graphics and more for only $20
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?

Add Comment

Discussion 131 Comments

Comment Page 2 of 2 1 2
  1. Ditto R K Asnar says:

    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

    • Esteban says:

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

    • 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.

    • 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 says:

      rake db:test:prepare

    • 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!

    • MaerF0x0 says:

      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

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

  3. Konstantin says:

    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

  4. aa says:

    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.

  5. Ernest says:

    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

    • Jeffrey Way says:
      Author

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

      • Samuel says:

        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

  6. Chris says:

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

  7. nija says:

    what is the solution of this event?

  8. Mauro says:

    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?

  9. Alex says:

    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.

  10. 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’

  11. Daniel says:

    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!

  12. Jason says:

    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!!!

    • Jason says:

      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.

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

      • Jason says:

        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 says:

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

  13. Albert says:

    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

  14. Brian Frichette says:

    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!

  15. Darragh Flynn says:

    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 >-<

  16. Edu says:

    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?

  17. Thomas Bush says:

    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 says:

      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.

  18. Christoph Rumpel says:

    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

  19. Daniel van Flymen says:

    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.

  20. Daniel van Flymen says:

    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.

Comment Page 2 of 2 1 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.