Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bringing together the different tableless model implementations into a single gem/plugin

tree: 5d16059c67

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 TODO
Octocat-spinner-32 activerecord-tableless.gemspec
Octocat-spinner-32 init.rb
README
ActiveRecord Tableless
----------------------

A single implementation of the ActiveRecord Tableless pattern for any Rails
project or other Ruby project that uses ActiveRecord.

Define a model like this:

class ContactMessage < ActiveRecord::Base
  has_no_table
  column :name, :string
  column :email, :string
  validates_presence_of :name, :email
end

You can now use the model in a view like this:

<%= form_for :message, @message do |f| %>
  Your name: <%= f.text_field :name %>
  Your email: <%= f.text_field :email %>
<% end %>

And in the controller:

def message
  @message = ContactMessage.new
  if request.post?
    @message.attributes = params[:message]
    if @message.valid?
      # Process the message...
    end
  end
end

Credits
-------
Michal Zima <xhire@tuxportal.cz>
Kenneth Kalmer <kenneth.kalmer@gmail.com> (original author)
Something went wrong with that request. Please try again.