Open bhavinkamani opened 13 years ago
After little more investigation, I am not able to make jammit work with rails 3.1 vendor assets. on giving vendor/assets/javascripts/*.js, it gives same path in my html.
<script src="/vendor/assets/javascripts/elastic.js" type="text/javascript"></script>
I have a hunch that I am missing something silly.
Ok, but there needs to be a way of running Jammit with rails 3.1 ?
I agree with Serek. After trying out sprockets, I feel jammit is far more intuitive. Specifically, I like the way jammit manages all assets under one roof (assets.yml) and asset extensions such as template etc. I certainly miss jammit big time in rails 3.1. Also, one should have option to choose asset pipeline engine. Isn't that a fundamental rails philosophy?
Jammit should work fine with Rails 3.1. Just use it as you would normally.
I tried to use it. I am stuck at urls. How should I refer assets within assets.yml. Here's my assets.yml file. I have a simple test.js under assets/javascripts folder. I dont see the ref of test.js in the html output.
config/assets.yml
compress_assets: off
javascripts:
workspace:
- assets/javascripts/test.js
app/views/layoutsapplication.html.erb
<%= include_javascripts :workspace %>
You wouldn't put JavaScripts in "assets" -- you'd leave them in "public", as before.
Whoops, my bad! Deleted my misleading comment.
Thanks a lot Jeremy... That works fine.
Is there a plan to allow reference to assets placed under assets/ folder. Also would one has to fall back on barista for coffeescript and compass for sass or can I use assets pipelining provided by tilt/sprockets?
No, there are no plans to allow assets to be placed under the assets folder -- they need to be somewhere publicly accessible by the web server. "public" is a great place for that. I don't know about what level of sprockets integration you'll be able to get -- you'll have to ask the sprockets folks about that.
@bhavinkamani -- I've always had my assets in app/javascripts
and app/stylesheets
. It's actually quite easy to use jammit with this set up. All you need to do is symlink public/app/javascripts => app/javascripts
. I have a hook in my config/environments/development.rb
to do it automatically:
# Symlink javascripts and stylesheets on the fly.
config.after_initialize do
if !File.exists?(File.join(Rails.root, 'public', 'app'))
Rails.logger.info "Linking from public/ to app/javascripts and app/stylesheets for Jammit's helpers."
`mkdir -p #{Rails.root}/public/app`
`ln -s #{Rails.root}/app/javascripts #{Rails.root}/public/app/javascripts`
`ln -s #{Rails.root}/app/stylesheets #{Rails.root}/public/app/stylesheets`
end
end
This way, in development when the assets are not packaged, the URLs work.
Thanks @agibralter for your reply. Thats a neat approach.
I liked the way tilt takes care of abstracting template engines. Similarly I like the way jammit takes care of asset packaging through one config file. Right now, it appears to me that if I want to use tilt I have to use sprockets or I have to use jammit with barista, compass and other separate gems for each templates. I would have liked to disable sprockets and enable jammit integrated with tilt. Not sure if there is already a way and I am missing something?
you could add your folder to the assets pipeline path:
config.assets.paths << "#{Rails.root}/public/packages"
i have my .js packed there.
I am experimenting with rails 3.1.
Rails is resolving assets url as assets/.js. It maps this to app/assets/jaavscripts/.js and vendor/assets/javascripts/*.js. app files gets priortiy then the vendor files.
I love jammit and would like to know if there is a way to enter assets/*.js url instead of explicit vendor or app url relative to root path in assets.yml file.
Please pardon my ignorance if something like this already exist and I am not aware of the same.