# Can i have a model called FILE.RB?

**URL:** <https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432>\
**Category:** Rails\
**Created:** [April 23, 2010, 2:46am UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432 "2010-04-23T02:46:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 23, 2010, 2:46am UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432/1 "2010-04-23T02:46:12Z")

</div>

Is “file” reserved? Can i use it for my model name? Because I am  
getting this error-

NoMethodError in FilesController#new

undefined method `quoted\_table\_name’ for File:Class

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 23, 2010, 3:49am UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432/2 "2010-04-23T03:49:26Z")

</div>

uGH! im answering my own questions!. sorry guys ill think b4 i post  
next time.

here are the reserved words-  
[http://newwiki.rubyonrails.org/rails/pages/reservedwords](http://newwiki.rubyonrails.org/rails/pages/reservedwords)

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 23, 2010, 7:26am UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432/3 "2010-04-23T07:26:34Z")

</div>

Thanks for sharing that URL.

Yeah, I’ve ran into a couple myself. Yeah, File is definitely a Ruby  
class name, which is inherited from the IO class. I tried making a  
model called both Application and Type in the same app actually. Let’s  
just say it didn’t go too well… 😉

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 23, 2010, 3:37pm UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432/4 "2010-04-23T15:37:48Z")

</div>

You can get by “reusing” a class name, but it’s a PITA.

I had a model named Filter, then upgraded Rails at one point, and all  
sorts of ugly conflicts occurred since the new version of Rails included  
a Filter clas.

One solution is to reference the class to the local namespace, such as  
in the controller:

@filters = ::Filter.find(blah blah blah)

While it can be done, I wouldn’t ever do it again.

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 23, 2010, 3:43pm UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432/5 "2010-04-23T15:43:51Z")

</div>

Ar Chron wrote:

> You can get by “reusing” a class name, but it’s a PITA.
> 
> I had a model named Filter, then upgraded Rails at one point, and all  
> sorts of ugly conflicts occurred since the new version of Rails included  
> a Filter clas.
> 
> One solution is to reference the class to the local namespace, such as  
> in the controller:
> 
> @filters = ::Filter.find(blah blah blah)

I believe that would be the global namespace, no?

> While it can be done, I wouldn’t ever do it again.

Yeah.

## Best,

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

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 23, 2010, 3:57pm UTC](https://www.ruby-forum.com/t/can-i-have-a-model-called-file-rb/187432/6 "2010-04-23T15:57:02Z")

</div>

On Apr 23, 2:43 pm, Marnen Laibow-Koser [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > @filters = ::Filter.find(blah blah blah)
> 
> I believe that would be the global namespace, no?

That works because ActionController creates ActionController::Filter,  
but ruby’s File class is also at the top level so I don’t think you’d  
have much luck there

Fred
