0.0
No commit activity in last 3 years
No release in over 3 years
BasicModel is intended to be used in a tableless model in Rails >= 3.0. It complies with the ActiveModel API and includes valdiations, so it can be used in form helpers without a problem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

< 5, >= 3.0
< 5, >= 3.0
 Project Readme

BasicModel

BasicModel is intended to be used in a tableless model in Rails >= 3.0. It complies with the ActiveModel API and includes validations, so it can be used in form helpers without a problem.

Installation

$ gem install basic_model

Usage

require 'basic_model'

class Message
  include BasicModel
  attr_accessor :name, :email, :content

  # can even include validations
  validates_presence_of :name
end

message = Message.new(:email => 'bob@example.com', :content => 'Hey man!')
message.valid?
message.errors[:name] # => ["can't be blank"]

Using ActiveModel::MassAssignmentSecurity:

require 'active_model'
require 'basic_model'

class Comment
  include BasicModel
  include ActiveModel::MassAssignmentSecurity
  attr_accessor :name, :comment, :spam
  attr_accessible :name, :comment
end

comment = Comment.new(:name => 'Bob', :comment => 'Great Post!', :spam => false)
comment.spam # => nil

Copyright

Copyright (c) 2011 Peter Browne. See LICENSE for details.