Intermediate Ruby on Rails - Part 1

Important question: what the hell happened at 25:00 ?

This guy types way too fast for a tutorial. It would be sweet if there was a speed reduce button on the video. I would listen to a deep slow voice the whole time over pushing pause 900 times.

I havenā€™t gone through this video, but Iā€™m assuming that theyā€™re using devise with it.

The easiest, and probably the best is to do it globally throughout the system ( if everything needs to be authenticated ). Sometimes iā€™ll have open routes and authenticated routes, in which case iā€™ll have my main application_controller being open, then iā€™ll have another application_controller elsewhere, that inherits from the main, and includes the code below.

Such as in your application_controller.rb like so:

class ApplicationController < ActionController::Base
  protect_from_forgery with: exception
  
  before_action :authorize_user!

  private
  def authorize_user!
    authenticate_user!
    unless current_user
      redirect_to root_path, alert: "you must be logged in to do that"
    end
  end
end

but, donā€™t forget your spec for it, because tests are important!

@MrNagoo You could use this Chrome extension to control the video speed: GitHub - igrigorik/videospeed: HTML5 video speed controller (for Google Chrome)

1 Like

Is there any plan to update this course for rails 4 (or even rails 5)? Rails 3 is a bit too old and is not as relevant as it used to be.

Iā€™m using ruby 2.2.3 and rails 4.2.6. When I issued the following command
rails g monban:scaffold
it displays as following

Using strong_parameters? y
conflict app/controllers/sessions_controller.rb
Overwrite /home/kenshinji/git/shouter/app/controllers/sessions_controller.rb? (enter ā€œhā€ for help) [Ynaqdh] a
force app/controllers/sessions_controller.rb
identical app/controllers/users_controller.rb
route resources :users, only: [:new, :create]
route resource :session, only: [:new, :create, :destroy]
identical app/views/users/new.html.erb
identical app/views/sessions/new.html.erb
/home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/generators/migration.rb:54:in migration_template': wrong number of arguments (1 for 2..3) (ArgumentError) from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/monban-0.0.6/lib/generators/monban/scaffold/scaffold_generator.rb:21:in copy_migrationā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in run' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_commandā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in block in invoke_all' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in eachā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in map' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in invoke_allā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatchā€™

ļæ½
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/generators.rb:157:in invokeā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/generate.rb:13:in <top (required)>' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in requireā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in block in require' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in load_dependencyā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in require' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:123:in require_command!ā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:130:in generate_or_destroy' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:50:in generateā€™
from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in run_command!' from /home/kenshinji/.rvm/rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in <top (required)>ā€™
from bin/rails:4:in require' from bin/rails:4:in ā€™

I had the same issue with `migration_templateā€™: wrong number of arguments.

Did you find a solution.

Hi. Iā€™d like to know if I can do this tutorial with Rails 4 and Ruby 2.2? Or is it preferred to install Rails 3 and Ruby 1.9? Will I have much trouble?

Thanks!

Iā€™ve done the first 3 parts with Rails 4 and Ruby 2.3.0 without too much trouble. There are bits of it that are clearly outdated, but the comment sections at the bottom of the videos have been great for suggesting updates/fixes.

This doesnā€™t seem right to me. Rails 3 and Ruby 1.9? There are many great Rails courses online but I respect Thoughtbotā€™s reputation and if they recommend a course of action I would consider it an ā€œIndustry Standardā€ so I happily signed up for a $29 per month subscription.

This should be under a section called ā€œOlder versions of Railsā€ so that I can choose to learn that if I want. Even if they just said ā€œHey, we arenā€™t going to build another intermediate Rails course, there are plenty, here are links to 5 of them that we recommend you check out, just keep in mind we disagree with x, y and z on this courseā€ then I would still consider it giving me appropriate value.

I trust and believe Thoughtbot is still staying on the cutting edge and has evolved their practices of how to build Rails apps enough that spending my efforts to learn how they did it 4 years ago is a waste of my time. Seeing this as the standard way of how they supposedly train their junior developers, must be a misunderstanding but it erodes away a bit of that trust.

1 Like

Spot on, Thoughtbot needs to answer to this. I finished a bootcamp, got a rails job and have been using rails 5 since beta 2, how would this help me? If it was at least 4 I would be able to learn things since 4 isnā€™t that different from 5.

I got the same error and canā€™t find a solution. Did you work out a way round it?

Just realised you need a more recent version of monban - I just bundled monban to get the latest version and the error doesnā€™t happen when you generate the scaffold.

yes, Iā€™ve figured it out, thanks :slight_smile:

He uses before_filter at 18:53, but this is deprecated in Rails 5. Use before_action instead. This goes for all other *_filter methods. Use the *_action methods in their place!

It would be really helpful if this trail included actual descriptions of what was covered in Parts 1-4. Same goes for the ReadMe of the repo weā€™re asked to fork for part 1. Thereā€™s almost no information explaining what weā€™ll be building.

Iā€™m getting a 404 error when I try to get to the github repo