Module: Opinio::Controllers::InternalHelpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- Opinio::CommentsController
- Defined in:
- lib/opinio/controllers/internal_helpers.rb
Instance Method Summary collapse
- #custom_resource_identifier(params) ⇒ Object
- #resource ⇒ Object
- #resource_by_params ⇒ Object
- #resource_name ⇒ Object
- #set_flash(name, message) ⇒ Object
Instance Method Details
#custom_resource_identifier(params) ⇒ Object
24 25 26 |
# File 'lib/opinio/controllers/internal_helpers.rb', line 24 def custom_resource_identifier(params) Opinio.check_custom_identifiers(params) end |
#resource ⇒ Object
10 11 12 |
# File 'lib/opinio/controllers/internal_helpers.rb', line 10 def resource @resource ||= custom_resource_identifier(params) || resource_by_params end |
#resource_by_params ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/opinio/controllers/internal_helpers.rb', line 14 def resource_by_params if params[:commentable_type] params[:commentable_type].constantize.find(params[:commentable_id]) elsif params[:comment] params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) else raise "Unable to determine comments holder" end end |
#resource_name ⇒ Object
28 29 30 |
# File 'lib/opinio/controllers/internal_helpers.rb', line 28 def resource_name Opinio.model_name end |
#set_flash(name, message) ⇒ Object
32 33 34 |
# File 'lib/opinio/controllers/internal_helpers.rb', line 32 def set_flash(name, ) flash[name] = if Opinio.set_flash end |