Module: HappyPath
- Defined in:
- lib/happy_path.rb,
lib/happy_path/version.rb
Constant Summary collapse
- PATHS =
['first', 'last']
- VERSION =
"0.0.7"
Instance Method Summary collapse
Instance Method Details
#follow_happy_paths ⇒ Object
12 13 14 15 16 |
# File 'lib/happy_path.rb', line 12 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 10 |
# File 'lib/happy_path.rb', line 4 def setup_happy_path rescue_from ActiveRecord::RecordNotFound do |e| class_constant = controller_name.classify.constantize rescue nil raise e unless class_constant && self.respond_to?(:happy_paths) && HappyPath::PATHS.include?(params[:id]) && !class_constant.count.zero? self.happy_paths(e, class_constant) end end |