Sha256: a79d6a1c601d922256692df6469e822375475b88e3d9dfa9a68c7501c110c5b2
Contents?: true
Size: 790 Bytes
Versions: 2
Compression:
Stored size: 790 Bytes
Contents
require 'active_record' require 'forwardable' module Rack::Scaffold::Adapters class ActiveRecord < Base extend Forwardable def_delegators :@klass, :count, :all, :find, :create!, :update!, :destroy! class << self def ===(model) ::ActiveRecord::Base === model end def resources(model, options = {}) model end def timestamps? record_timestamps? end end def singular @klass.name.downcase end def plural @klass.table_name end def paginate(limit, offset) @klass.limit(limit).offset(offset) end def [](id) self.find(id) end def update_timestamp_field self.attribute_names.include?("updated_at") ? "updated_at" : "updated_on" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rack-scaffold-0.0.3 | ./lib/rack/scaffold/adapters/active_record.rb |
rack-scaffold-0.0.2 | ./lib/rack/scaffold/adapters/active_record.rb |