Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
BasicActiveModel provides a minimal architecture for a model that may be used in Rails forms.
Ruby
Branch: master
Failed to load latest commit information.
lib first commit
spec first commit
.gitignore first commit
Gemfile first commit
Gemfile.lock first commit
LICENSE first commit
README.textile adds warning about Rails 3 comp only.
Rakefile first commit
VERSION first commit
basic_active_model.gemspec adds gemspec
init.rb first commit

README.textile

BasicActiveModel

BasicActiveModel provides a minimal architecture for a model that may be used in Rails forms.
It does not provide any kind of implementation. It may be used to create static models (search, contact us, etc.).

It includes ActiveModel validations and may be initialized with an argument Hash with optional mass assignment security.

Please take a look of the specs for more information…

Installation

WARNING : this gem uses ActiveModel and therefore is only compatible with Rails 3.

In your Gemfile:

  gem "basic_active_model"

Example

  class ContactUs < BasicActiveModel
    attr_accessor :email, :subject, :body, :admin
    attr_accessible :email, :subject, :body
    validates_presence_of :body
  end
  
  ...
  (in the view)
  ...
  = form_for @contact_us do |f|
    = f.text_field :email
  ...
  
  ...
  (in the ContactUs controller)
  ...
  
  @contact_us = ContactUs.new(params[:contact_us])
  if @contact_us.valid?
    ...
Something went wrong with that request. Please try again.