Module: HappyPath
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/happy_path.rb,
lib/happy_path/version.rb
Constant Summary collapse
- PATHS =
['first', 'last']
- VERSION =
"0.0.2"
Instance Method Summary collapse
Instance Method Details
#follow_happy_paths ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/happy_path.rb', line 9 def follow_happy_paths define_method (:happy_paths) do |exception| class_constant = controller_name.classify.constantize raise exception unless self.respond_to?(:show) && HappyPath::PATHS.include?(params[:id]) && !class_constant.count.zero? redirect_to action: :show, id: class_constant.send(params[:id]).id end end |
#setup_happy_path ⇒ Object
5 6 7 |
# File 'lib/happy_path.rb', line 5 def setup_happy_path rescue_from ActiveRecord::RecordNotFound, with: :happy_paths end |