This class create a fake table that can be usefull if you need for example perform validations. Take a look to this test case:
Examples:
class Contact < Lipsiadmin::DataBase::WithoutTable
column :name, :string
column :company, :string
column :telephone, :string
column :email, :string
column :message, :text
validates_presence_of :name, :message
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
end
Now we need to validate a contact, and if the validations is okey send an email or if not raise errors
@contact = Contact.new(params[:contact])
if @contact.valid?
Notifier.deliver_support_request(@contact)
else
flash[:notice] = "There are some problems"
render :action => :support_request
end
Methods
Public Class methods
Define columns for a this fake table
[ show source ]
# File lib/data_base/without_table.rb, line 43
43: def column(name, sql_type = nil, default = nil, null = true)
44: columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
45: reset_column_information
46: end
Returns columns for this fake table
[ show source ]
# File lib/data_base/without_table.rb, line 38
38: def columns()
39: @columns ||= []
40: end
Resets all the cached information about columns, which will cause them to be reloaded on the next request.
[ show source ]
# File lib/data_base/without_table.rb, line 49
49: def reset_column_information
50: generated_methods.each { |name| undef_method(name) }
51: @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = nil
52: end