On Mon, Aug 16, 2010 at 1:27 PM, Fernando Perez <[email protected]>wrote:
Here is what I do:

class Tableless < ActiveRecord::Base
 def self.columns
   @columns ||= [];
 end

 def self.column(name, sql_type = nil, default = nil, null = true)
   columns << ActiveRecord::
>
> ConnectionAdapters::Column.new(name.to_s,
> default, sql_type.to_s, null)
>  end
> end
>
> Class Contact < Tableless
>  column :address, :string
>  column :message, :text
>
>  validates_presence_of :message, :address
> end
>
>
> It works perfectly in Rails 2.3.8, it might break in Rails 3 I haven't
> tested yet.



Thanks Fernando. That is exactly what I was doing (but getting an error) but
your telling me it works perfectly for you made me look further and I found
an error in a field name that I was validating --- so now all works well.
Good to have confirmation that this structure is being used successfully by
others.

David

On Mon, Aug 16, 2010 at 1:27 PM, Fernando Perez <[email protected]>wrote:

> Here is what I do:
>
> class Tableless < ActiveRecord::Base
>  def self.columns
>    @columns ||= [];
>  end
>
>  def self.column(name, sql_type = nil, default = nil, null = true)
>    columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s,
> default, sql_type.to_s, null)
>  end
> end
>
> Class Contact < Tableless
>  column :address, :string
>  column :message, :text
>
>  validates_presence_of :message, :address
> end
>
>
> It works perfectly in Rails 2.3.8, it might break in Rails 3 I haven't
> tested yet.
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to