Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
File object. Undefined methods
Olivier Moratin
5/8/2009 6:50:00 PM
Hi
I'm doing the following in the console of a Rails app
>> file = File.open("#{RAILS_ROOT}/xml/feed.xml")
=> #<File:/WebApps/app/xml/feed.xml>
>> f.dirname
NoMethodError: undefined method `dirname' for
#<File:/WebApps/app/xml/feed.xml>
I've tried other methods written in the doc of the File class to no
avail.
What am I missing?
Thanks
--
Posted via
http://www.ruby-...
.
1 Answer
Tim Hunter
5/8/2009 7:51:00 PM
0
Olivier Moratin wrote:
> Hi
>
> I'm doing the following in the console of a Rails app
>
>>> file = File.open("#{RAILS_ROOT}/xml/feed.xml")
> => #<File:/WebApps/app/xml/feed.xml>
>>> f.dirname
> NoMethodError: undefined method `dirname' for
> #<File:/WebApps/app/xml/feed.xml>
>
> I've tried other methods written in the doc of the File class to no
> avail.
>
> What am I missing?
>
> Thanks
Read the doc very carefully. dirname is a singleton method in File, not
an instance method.
File.dirname("#{RAILS_ROOT}/xml/feed.xml")
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
File object. Undefined methods
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password