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