开发者

Rails 3: Application not picking up image files

开发者 https://www.devze.com 2023-02-13 17:47 出处:网络
Bit of a newbie question. I can\'t seem to get my application to pick up images that I have in a local folder ( public/stylesheets/images/XYZ/*.png). As a result

Bit of a newbie question. I can't seem to get my application to pick up images that I have in a local folder ( public/stylesheets/images/XYZ/*.png). As a result my main page is rendered without some essential graphics.

In my HAML file, I have tags defined as follows: %img{:src => '/images/XYZ/scissor.png'}

This leads 开发者_StackOverflow中文版to calls like: Started GET "/images/dookum.in/scissor.png' for 127.0.0.1 ....

and error messages like: ActionController::RoutingError (No route matches "/images/dookum.in/scissor.png')

I don't know why this is happening. Do I need to define RAILS_ROOT? Or change routes.rb? If yes, then how?

Thanks for your help Abhinav


You may try to add following setting in your environment files

config.serve_static_assets = true


Either you write

= image_tag('scissor.png')

and this will look for the file /public/images/scissor.png, or you should specify stylesheets/images/XYZ/...

Everything under /public is served in development mode, if you want you rails process to serve everything under /public in production-mode, you have to set the config.serve_static_assets to true.

0

精彩评论

暂无评论...
验证码 换一张
取 消