RailsCasts Pro episodes are now free!

Learn more or hide this

Matt Powell's Profile

GitHub User: matpowel

Site: www.agworld.com.au

Comments by Matt Powell

Avatar

Hi all,

I've had a few people ask, just so you know I ended up having to implement Tableless like this to get it going with Rails 3.1 and working with associations.

Put this in your app/models dir and then extend it to get a tableless model that still supports all the associations like has_many, belongs_to etc, validations and basically smells like a real model.

We use it a fair bit for things like filter models, giving us very clean view and controller code.

https://gist.github.com/1101257

Enjoy.
//matt

Avatar

Hi Ryan,

Thanks again for the Railscast.

I'm upgrading our Rails 2.3.11 app straight to 3.1 and my old tableless models don't work anymore (as per screencast #193). This stuff in this railscast looks nice and clean but I'm a little confused why no one else is coming up against the problem of no longer getting access to associations and the SQL Column benefits of the old way.

We use things like:

column :option, :string, "Default"

and

has_many :areas
accepts_nested_attributes_for :areas

Is there some ActiveRecord goodness we can include/extend?

If not, the actual problem we have is that as of Rails 3.1 the tableless models are trying to hit the DB looking for "tablelesses" when initializing etc.

Thanks,
Matt