Sha256: 712fdd4edd43d24441b134597c61b83bb54a8c0b802693ea71ef8dd24564f654

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

module PowerResource
  class BaseController < ::ApplicationController
    inherit_resources
    defaults route_prefix: ''

    include PowerResource::BaseHelper

    def create
      create! { collection_url }
    end

    def update
      update! { collection_url }
    end

    protected

    def permit_attributes
      # Override this method in your controller:
      #
      #   class PostsController < PowerResource::BaseController
      #     def permit_attributes
      #       %w(title content)
      #     end
      #   end
      #
      # Or add default behaviour in your ApplicationController:
      #
      #   class ApplicationController < ActionController::Base
      #     def permit_attributes
      #       resource_human_attributes
      #     end
      #   end
    end

    def permitted_params
      params.permit(
        resource_name => permit_attributes
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
power_resource-0.0.3 app/controllers/power_resource/base_controller.rb
power_resource-0.0.2 app/controllers/power_resource/base_controller.rb