# Table less model

**URL:** <https://www.ruby-forum.com/t/table-less-model/169310>\
**Category:** Rails\
**Created:** [June 2, 2009, 5:31am UTC](https://www.ruby-forum.com/t/table-less-model/169310 "2009-06-02T05:31:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [June 2, 2009, 5:31am UTC](https://www.ruby-forum.com/t/table-less-model/169310/1 "2009-06-02T05:31:43Z")

</div>

I want to have a simple model without a table for ACL purposes because  
there aren’t going to be many methods at all.

How could I have a Model like…

ControllerMethod securitylevel

users\_list 8  
reports\_ar 6  
ar\_print\_checks 7

so I can use retrieve and use these values in a before\_filter in  
ApplicationController.rb? The intent is to create a lightweight ACL  
system.

I don’t see the need to actually create a table or store the data in a  
table at all.

Any suggestions on how I can accomplish this?

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [June 2, 2009, 6:16am UTC](https://www.ruby-forum.com/t/table-less-model/169310/2 "2009-06-02T06:16:07Z")

</div>

If your model isn’t abstracting the DB in anyway, just don’t have it  
inherent from ActiveRecord::Base… or perhaps I’m not understanding  
part of your question?

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [June 2, 2009, 6:25am UTC](https://www.ruby-forum.com/t/table-less-model/169310/3 "2009-06-02T06:25:43Z")

</div>

pharrington wrote:

> If your model isn’t abstracting the DB in anyway, just don’t have it  
> inherent from ActiveRecord::Base…

Exactly. Also, I recommend that you (the OP, that is) take a look at  
Authlogic, which uses a tableless model for user authentication; perhaps  
it will do what you want.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [June 3, 2009, 12:43am UTC](https://www.ruby-forum.com/t/table-less-model/169310/4 "2009-06-03T00:43:34Z")

</div>

On Tue, 2009-06-02 at 06:25 +0200, Marnen Laibow-Koser wrote:

> pharrington wrote:
> 
> > If your model isn’t abstracting the DB in anyway, just don’t have it  
> > inherent from ActiveRecord::Base…
> 
> Exactly. Also, I recommend that you (the OP, that is) take a look at  
> Authlogic, which uses a tableless model for user authentication; perhaps  
> it will do what you want.

* * *

Authlogic too was overkill for my purposes and yes, I didn’t need a  
ActiveRecord::Base at all, just an indexed hash was all I needed. I just  
had to keep it simple.

Thanks

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [June 3, 2009, 9:07am UTC](https://www.ruby-forum.com/t/table-less-model/169310/5 "2009-06-03T09:07:49Z")

</div>

class ModelName \< ActiveRecord::Base

# Add Following lines in a model

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  
On Wed, Jun 3, 2009 at 4:11 AM, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Authlogic too was overkill for my purposes and yes, I didn’t need a  
> dangerous content by MailScanner, and is  
> believed to be clean.
> 
> >

–  
Ruby on Rails, j2ee Developer

> **[Blogs - Neuigkeiten - Artikel - Webseiten - Medien](https://www.sosblog.com/)**
>
> Auf SOSblog geht es um aktuelle Blogs, Neuigkeiten, Artikel, Webseiten und Medien. Wir bringen interessante neue Webseiten aus den Tiefen des Webs.

> **[Josh Software | Custom Software Development Services & Solutions](https://joshsoftware.com/)**
>
> JoshSoftware offers custom software development Services & Solution that provides enterprise, software development services for web & mobile.
