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
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
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
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…
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.
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.
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
On Apr 23, 2:43 pm, Marnen Laibow-Koser [email protected] 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs