-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include JS in layout with rails helper #2215
Conversation
Use Rails helper to include javascript. Assets pipeline divides manifest into separate files if assets.debug is true
Could you elaborate more on what this solves? |
Therу is a common rails interface to include assets in layout. This is For example: In active_admin initializer: config.register_javascript 'my_javascript' my_javascript.js is a manifest file with
I see one file in html in development instead of four. Inspite of By the way, stylesheets are included with rails tag (https://github.com/gregbell/active_admin/blob/master/lib/active_admin/views/pages/base.rb#L27). It would be better to include js the same way for consistency |
That doesn't quite work as I expected. With this change, all of these script tags showed up in the HTML: <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/lib/namespace.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/components/jquery.aa.checkbox-toggler.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/components/jquery.aa.dropdown-menu.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/components/jquery.aa.popover.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/components/jquery.aa.table-checkbox-toggler.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/pages/application.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/pages/batch_actions.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/application.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin/base.js?body=1" type="text/javascript"></script>
<script src="/assets/active_admin.js?body=1" type="text/javascript"></script> Do you have any idea what /assets/active_admin.js # returns the compiled version
/assets/active_admin.js?body=1 # returns an empty file |
What do you expected? This is exactly what I want. This is extremly convenient in development mode. And it is very easy to turn off.
It's ok. There is no any js code in |
It doesn't work how I'd expect because:
Do you know why the |
This is sprockets feature See http://stackoverflow.com/questions/7820333/rails-3-assets-add-body-1 You can see this parameter used here: |
Thanks for abiding my laziness :] Looks good. It'll be much easier to debug Javascript in the browser with this change. Thanks! 🐱 |
Include JS in layout with rails helper
Thank you :) |
Use Rails helper to include javascript. Assets pipeline divides manifest into separate files if assets.debug is true