← Back to Upcase

Intermediate Ruby on Rails - Part 1

(Patrick) #23

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

(MrNagoo) #24

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.

(Justin Black) #25

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!

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

but, don’t forget your spec for it, because tests are important!

(Andy Waite) #26

@MrNagoo You could use this Chrome extension to control the video speed: https://github.com/igrigorik/videospeed

(Daniel Chinedu) #27

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.

(kenshinji) #28

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:incopy_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:ininvoke_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:ineach’
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:ininvoke_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:ininvoke’
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:inrequire’
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:inload_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:inrequire_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:ingenerate’
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

(Brian Ward) #29

I had the same issue with `migration_template’: wrong number of arguments.

Did you find a solution.

(Jon M) #30

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?


(Josh Rider) #31

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.

(De Wet Blomerus) #32

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.

(Mike Robinson) #33

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.

(Ollie Haydon-Mulligan) #34

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

(Ollie Haydon-Mulligan) #35

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.

(kenshinji) #36

yes, I’ve figured it out, thanks :slight_smile:

(Oktober Comstock) #37

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!

(wes) #38

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.

(joe) #39

I’m getting a 404 error when I try to get to the github repo