Module: HappyPath::ClassMethods

Defined in:
lib/happy_path.rb

Instance Method Summary collapse

Instance Method Details

#happy_paths(exception) ⇒ Object



11
12
13
14
15
# File 'lib/happy_path.rb', line 11

def happy_paths(exception)
  class_constant = controller_name.classify.constantize
  raise exception unless ["first","last"].include?(params[:id]) || class_constant.count.zero?
  redirect_to action: :show, id: class_constant.send(params[:id]).id
end