Sha256: e9b0ef6b0f0600af72898517e0429b10c376b12b8f03ee47328d0edbfa3b6a8c

Contents?: true

Size: 805 Bytes

Versions: 3

Compression:

Stored size: 805 Bytes

Contents

module ResourcesController
  module RestResourceUrls
    extend ActiveSupport::Concern

    included do
      helper_method :new_resource_path
      helper_method :collection_path
      helper_method :resource_path
      helper_method :edit_resource_path
    end

    private

    def new_resource_path
      resource_router.send(:url_for, { action: :new, only_path: true })
    end

    def collection_path
      resource_router.send(:url_for, { action: :index, only_path: true })
    end

    def resource_path(resource)
      resource_router.send(:url_for, { action: :show, id: resource, only_path: true })
    end

    def edit_resource_path(resource)
      resource_router.send(:url_for, { action: :edit, id: resource, only_path: true })
    end

    def resource_router
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-add_ons-3.0.0.pre1 app/concerns/resources_controller/rest_resource_urls.rb
rails-add_ons-2.2.1 app/concerns/resources_controller/rest_resource_urls.rb
rails-add_ons-2.2.0 app/concerns/resources_controller/rest_resource_urls.rb