Module: Releaf::ActionController::Urls
- Extended by:
- ActiveSupport::Concern
- Included in:
- Releaf::ActionController
- Defined in:
- app/lib/releaf/action_controller/urls.rb
Instance Method Summary collapse
- 
  
    
      #current_path  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns current path without internal params. 
- 
  
    
      #index_path  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Returns index path for current request. 
- #resolve_index_path ⇒ Object
- 
  
    
      #success_path  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Returns path to redirect after successul resource create/update actions. 
- #valid_index_path?(value) ⇒ Boolean
Instance Method Details
#current_path ⇒ Object
Returns current path without internal params
| 46 47 48 | # File 'app/lib/releaf/action_controller/urls.rb', line 46 def current_path @current_path ||= [request.path, (request.query_parameters.to_query if request.query_parameters.present?)].compact.join("?") end | 
#index_path ⇒ String
Returns index path for current request
| 22 23 24 | # File 'app/lib/releaf/action_controller/urls.rb', line 22 def index_path @index_path ||= resolve_index_path end | 
#resolve_index_path ⇒ Object
| 26 27 28 29 30 31 32 33 34 35 36 37 | # File 'app/lib/releaf/action_controller/urls.rb', line 26 def resolve_index_path # use current url if action_name == "index" current_path # use from get params elsif valid_index_path?(params[:index_path]) params[:index_path] # fallback to index view else url_for(action: :index, only_path: true) end end | 
#success_path ⇒ String
Returns path to redirect after successul resource create/update actions
| 11 12 13 14 15 16 17 | # File 'app/lib/releaf/action_controller/urls.rb', line 11 def success_path if create_another? url_for(action: :new, only_path: true) else url_for(action: :edit, id: @resource.id, only_path: true, index_path: index_path) end end | 
#valid_index_path?(value) ⇒ Boolean
| 39 40 41 | # File 'app/lib/releaf/action_controller/urls.rb', line 39 def valid_index_path?(value) value.present? && value.is_a?(String) && value.first == "/" end |