dare ruby wrote:
> I have used code :
>
> if File.exists? RAILS_ROOT + "/public/images/bannerlist/#{params[:id]}"
Firstly, start using Pathname. I always put this in environment.rb:
require 'pathname'
RailsRoot = Pathname.new(RAILS_ROOT).expand_path
That allows this:
if (RailsRoot + 'public/images/bannerlist' + params[:id]).exist?
> a = File.read("public/images/bannerlist/martin2.gif")
That .read() call neglects the RAILS_ROOT. Never guess what the current folder
is; always use complete paths.
Next, you are essentially reading a gif into memory and barfing it out into a
file. This is slow, fragile, and high-risk. Consider using FileUtils to symlink
the banner.gif to the rotating banner in the banner list.
--
Phlip
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---