Jatin Kumar wrote in post #962248:> In my controller method, I am doing this
>
> File.open ("#{RAILS_ROOT}/directory/
> #{params[:file_name]}.#{params[:file_type]}", ''w'')
do |f|
> f.write(params[:file_body])
> end
>
> but I am getting this error
>
> NoMethodError (undefined method ` '' for
> #<ProgramsController:0xb66b4354>):
>
> I have tried passing the absolute path and still it doesn''t work.
And
> I have also tried escaping the whitespace between ".open" and
> "("...still doesn''t work.
> I don''t know what I am doing wrong and how can I fix it?
Hi Jatin Kumar,
It''s work for me. I am testing this on console. Please try this.
>> file_name = "test"
=> "test">> ext_name = "txt"
=> "txt">> File.open("#{RAILS_ROOT}/directory/#{file_name}.#{ext_name}",
"w") do |f|
f.write("Hello World!") end
=> 12>>
--
Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.