Search code examples
javascriptruby-on-railsimageasset-pipelinelightbox2

Lightbox Rails Asset Pipeline misunderstanding


I'm unsure as to why my close and loading images aren't loading when lightbox is called on my rails app. I've correctly copied over the files and and the js and css is working fine but I'm getting broken images for close and loading.

Here is application.js

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require justgage
//= require raphael.min
//= require jquery.purr
//= require best_in_place
//= require lightbox
//= require_tree .

My application.css

 *
 *= require jquery.ui.datepicker
 *= require_self
 *= require_tree .
 *= bootstrap
 *= lightbox
 */

And in my images folder I have close.png and loading.gif

Here is the output from the request

Started GET "/images/close.png" for IP at 2013-01-01 12:39:19 -0800
ActionController::RoutingError (No route matches [GET] "/images/close.png"):
  actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.8) lib/rails/engine.rb:479:in `call'
  railties (3.2.8) lib/rails/application.rb:223:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /Users/tony/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
  /Users/tony/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
  /Users/tony/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

And a similar error is shown for the loading.gif

Do I need to change something in my routes file? What am I overlooking here? If I correctly included the js and css shouldn't the images be included appropriately as well? Thanks for your attention and for taking a look.

------UPDATE-------

update application.css

 *= require jquery.ui.datepicker
 *= require_self
 *= require bootstrap
 *= require lightbox
 *= require_tree .
 */

same broken images still appear.


Solution

  • Take a look at this :

    *= require_tree .
    *= bootstrap
    *= lightbox
    */
    

    If it is really in your application.css , it should be :

    *= require bootstrap
    *= require lightbox
    *= require_tree .
    */
    

    EDIT : You can take a look at the lightbox.css file and check how are the images referenced . Then you should chose how to change it - hard-coded , like images/image.png with normal .css file prefix , or by <% asset_path %>/image.png and .css.erb .