Skip to content

Instantly share code, notes, and snippets.

@JudeOstorn
Created January 12, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JudeOstorn/d8e2fac730915d0d7662718086635702 to your computer and use it in GitHub Desktop.
Save JudeOstorn/d8e2fac730915d0d7662718086635702 to your computer and use it in GitHub Desktop.
ror_test
module SuperEngine
# время поджимало вот что в голову пришло. дайте совет сделаю по другому
def max_speed(_a)
150
end
end
class Car
include SuperEngine
def max_speed(super_info: false)
!super_info ? 90 : super
end
end
puts Car.new.max_speed # -> 90
# как с помощью модуля переопределить метод класса, чтобы результат был такой:
puts Car.new.max_speed(super_info: true) # -> 150
require 'active_record'
# что бы вы изменили в этом коде?
class Note < ActiveRecord::Base
def created_in_future?
created_at >= Time.now
end
end
# please refactor this
class UsersController < ApplicationController
def create
# тут длинная строка - не хватило времени решить как сделать её короче.
@user = User.build_from_omniauth(params[:user][:omniauth]) if params[:user][:omniauth].present?
@user ||= User.create(user_params)
after_create if @user.valid?
redirect_to new_user_path
end
def after_create
UserMailer.welcome_mail(@user).deliver
redirect_to root_path
end
private
def user_params
params.require(:user).permit(:email, :password,
:password_confirmation, :name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment