Skip to content

Instantly share code, notes, and snippets.

@guiltry
Last active August 29, 2015 14:19
Show Gist options
  • Save guiltry/fbcd99f9bc448454e070 to your computer and use it in GitHub Desktop.
Save guiltry/fbcd99f9bc448454e070 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
end
class Knight < User
end
class Archer < User
end
class UserController < ApplicationController
def create
@user = User.new(user_params)
if user_params[:type] == "Knight"
@user.increase_strength(10)
@user.decrease_agility(4)
elsif user_params[:type] == "Archer"
@user.decrease_strength(6)
@user.increase_agility(8)
end
# ...
end
end
class Admin::UserController < ApplicationController
def create
@user = User.new(user_params)
if user_params[:type] == "Knight"
@user.increase_strength(10)
@user.decrease_agility(4)
elsif user_params[:type] == "Archer"
@user.decrease_strength(6)
@user.increase_agility(8)
end
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment