No commit activity in last 3 years
No release in over 3 years
This "acts_as" extension provides the capabilities for selecting default model according to scope.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

ActsAsHasDefault

Description

This acts_as extension provides the capabilities for selecting default model. The class that has this specified needs to have a default column defined as a boolean on the mapped database table.

Installation

In your Gemfile:

gem 'acts_as_has_default'

Example

At first, you need to add a default column to desired table:

rails g migration AddDefaultToAddress default:boolean
rake db:migrate

After that you can use acts_as_has_default method in the model:

class Customer < ActiveRecord::Base
  has_many :addresses
end
    
class Address < ActiveRecord::Base
  belongs_to :customer
  acts_as_has_default scope: :customer_id
end