What you want to do is:
File.new(@page.title + ''.txt'', ''w'' ) {|file|
file << ''content'' }
Above the "file << ''content''" makes sure that
the file pointer is
closed after the content is written instead of leaving it open as in
your example "file.write( ''testfile'' )".
--
Thiago Jackiw
http://www.railsfreaks.com
On May 17, 6:38 am, GA Gorter
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I ned to create a file of the name of a variable?
> but i can''t create an extension.
>
> File.new((@page.title), ''w'' ) {|file| file.write(
''testfile'' )}
>
> how can i maka a extension like this
>
> File.new((@page.title.txt), ''w'' ) {|file| file.write(
''testfile'' )}
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---