On Monday, March 17, 2014 9:08:53 PM UTC-4, Ruby-Forum.com User wrote:
>
> Hello,
>
> Just upgraded to rails 4 and Bootstrap 3. Everything working fine
> except the following line in assets/javascripts/questions.js.coffee:
>
> $('#jumbotron').css('background-image' :'url("assets/Jumbotron2.png")')
>
> Works in development but not production on Heroku. Image just does not
> show up on Heroku.
>
> Tried $('#jumbotron').css('background-image' :url(<%= asset_path
> 'Jumbotron2.png' %>))
> which also worked in dev but not production. Changing application.js to
> application.js.erb crashed heroku.
>
> Any ideas?
>
> Thanks,
> Dave Castellano
>
> --
> Posted via http://www.ruby-forum.com/.
>
Yes. That's going to be an issue. I'm not sure I can explain it well, but
whenever you reference assets/ or asset_path, it needs to resolve that
through sprockets. In production, all assets are pre-compiled and
sprockets isn't loaded. when you use javascript to change the css to
reference an asset_path, there's no resolution. This doesn't happen in
development because assets aren't precompiled and these paths can be
resolved after changes to the css by javascript.
I would probably put the image in public/images/Jumbotron2.png and change
your code the the following:
$('#jumbotron').css('background-image' :'url("images/Jumbotron2.png")')
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/de857c23-c5d5-42a1-9c18-12d1db42aa5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.