0.01
No release in over 3 years
Low commit activity in last 3 years
Adds singleton functionallity to ActiveRecord models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

~> 4.0.0
 Project Readme

Singleton Rails

Gem Version Dependency Status Code Climate

Adds singleton functionallity to ActiveRecord models.

Supported Rails versions: 4.0.6 or higher

Licensed under the MIT license, see LICENSE for more information.

Installation

$ gem install singleton-rails

Usage

Include Singleton in your model

class AboutPage < ActiveRecord::Base
  include ActiveRecord::Singleton
end

Configure rails_admin

RailsAdmin.config do |config|

  config.actions do
    dashboard

    index &RailsAdmin::Config::Actions::SingletonAwareIndex::PATCH
    new &RailsAdmin::Config::Actions::SingletonAwareNew::PATCH
    export
    history_index
    bulk_delete

    show
    edit
    delete &RailsAdmin::Config::Actions::SingletonAwareDelete::PATCH
    history_show
    show_in_app
  end

end

How to use it in your controller

  class AboutPageController < ApplicationController
    def index
      @about_page = AboutPage.instance
    end
  end

Credits

Hyper made this. We're a digital communications agency with a passion for good code, and if you're using this library we probably want to hire you.