The document discusses the asset pipeline feature introduced in Rails 3.1. It addresses some of the pain points of managing assets in previous Rails versions, such as disorganized file structures and dependencies. The asset pipeline aims to make assets first-class citizens by introducing a conventional directory structure, generators, and dependency declarations. It also supports CoffeeScript, Sass, and other preprocessing of assets. In production, the pipeline compiles assets into a public directory, adding cache-busting hashes to filenames to improve caching.
Crossing the Bridge: Connecting Rails and your Front-end FrameworkDaniel Spector
Presented at Railsconf 2015 by Daniel Spector, @danielspecs.
Crossing the Bridge explores tools, patterns and best practices to connect your Javascript MVC framework to Rails in the most seamless way possible. The talk progresses from demonstrating the standard API request cycle to preloading data to your client-side framework to rendering your javascript on the server. It explores Isomorphic Javascript and ways of implementing it with Rails.
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
If you're like me, you know that being a great backend developer isn't enough. To make *truly* great applications, we need to spend significant time in an area that's moving at a lightning pace: frontend development.
This talk is for you: the backend developer that wants to hook their API's up to rich, interactive JavaScript frontends. To do that, first, we need to demystify a lot of new terms, like ES6/ES2015, ECMAScript, JSX, Babel and the idea that modern JavaScript (surprise) *requires* a build step.
With this in mind, I'll give you a brief introduction into Webpack & the modular development it finally allows.
But the real star is ReactJS. In the frontend world, you never know what new tech will *win*, but React is a star. I'll give you enough of an intro to get you rolling on your project.
The new frontend dev world is huge! Consider the starting line down an exciting new journey.
Refactoring Large Web Applications with Backbone.jsStacy London
Have you ever starting working on a large, existing web application and jQuery spaghetti-code is all over the place? Your mind swirls as you try to figure out what code belongs to what component on what page. There are no JavaScript unit tests and you're terrified of making a change and breaking everything? I'm going to talk through the real life story of how Backbone.js helped to bring organization/structure, modularity, and testability to a large multi-page web application.
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014Amazon Web Services
For both new and experienced users of the AWS SDK for PHP, we highlight features of the SDK as we work through building a simple, scalable PHP application. Attendees will learn about core features of the SDK including service clients, iterators, and waiters. We will also introduce new features in the upcoming Version 3 of the SDK, including asynchronous requests, paginators, and the new JMESPath result querying syntax.
AngularJS with Slim PHP Micro FrameworkBackand Cohen
AngularJS is a popular front-end framework that can be used with many server-side technologies. In many AngularJS web applications, each web page is really a single-page application (SPA), so the role of the server-side is really an API consisting of a set of web services to interact with the server-side database
In The Trenches With Tomster, Upgrading Ember.js & Ember DataStacy London
A few months after I started working with Ember.js & Ember Data at my new job we began a project to upgrade both. There were parts that were a breeze and others that were quite tricky. This talk walks you through some of the challenges we faced and how we solved them as well as how we began to prepare for the Ember 2.x architectural shift. Hopefully this talk will help save you some time when you decide to upgrade your Ember web application.
Laravel is a PHP MVC based framework. It is as easy as codeigniter, yet provides powerful tools needed for large robust application.It is built on top of symphony components and is inspired by many other frameworks including RoR, Asp .net, Sinatra.This session focuses on the basics things needed to start building application on it.
Crossing the Bridge: Connecting Rails and your Front-end FrameworkDaniel Spector
Presented at Railsconf 2015 by Daniel Spector, @danielspecs.
Crossing the Bridge explores tools, patterns and best practices to connect your Javascript MVC framework to Rails in the most seamless way possible. The talk progresses from demonstrating the standard API request cycle to preloading data to your client-side framework to rendering your javascript on the server. It explores Isomorphic Javascript and ways of implementing it with Rails.
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
If you're like me, you know that being a great backend developer isn't enough. To make *truly* great applications, we need to spend significant time in an area that's moving at a lightning pace: frontend development.
This talk is for you: the backend developer that wants to hook their API's up to rich, interactive JavaScript frontends. To do that, first, we need to demystify a lot of new terms, like ES6/ES2015, ECMAScript, JSX, Babel and the idea that modern JavaScript (surprise) *requires* a build step.
With this in mind, I'll give you a brief introduction into Webpack & the modular development it finally allows.
But the real star is ReactJS. In the frontend world, you never know what new tech will *win*, but React is a star. I'll give you enough of an intro to get you rolling on your project.
The new frontend dev world is huge! Consider the starting line down an exciting new journey.
Refactoring Large Web Applications with Backbone.jsStacy London
Have you ever starting working on a large, existing web application and jQuery spaghetti-code is all over the place? Your mind swirls as you try to figure out what code belongs to what component on what page. There are no JavaScript unit tests and you're terrified of making a change and breaking everything? I'm going to talk through the real life story of how Backbone.js helped to bring organization/structure, modularity, and testability to a large multi-page web application.
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014Amazon Web Services
For both new and experienced users of the AWS SDK for PHP, we highlight features of the SDK as we work through building a simple, scalable PHP application. Attendees will learn about core features of the SDK including service clients, iterators, and waiters. We will also introduce new features in the upcoming Version 3 of the SDK, including asynchronous requests, paginators, and the new JMESPath result querying syntax.
AngularJS with Slim PHP Micro FrameworkBackand Cohen
AngularJS is a popular front-end framework that can be used with many server-side technologies. In many AngularJS web applications, each web page is really a single-page application (SPA), so the role of the server-side is really an API consisting of a set of web services to interact with the server-side database
In The Trenches With Tomster, Upgrading Ember.js & Ember DataStacy London
A few months after I started working with Ember.js & Ember Data at my new job we began a project to upgrade both. There were parts that were a breeze and others that were quite tricky. This talk walks you through some of the challenges we faced and how we solved them as well as how we began to prepare for the Ember 2.x architectural shift. Hopefully this talk will help save you some time when you decide to upgrade your Ember web application.
Laravel is a PHP MVC based framework. It is as easy as codeigniter, yet provides powerful tools needed for large robust application.It is built on top of symphony components and is inspired by many other frameworks including RoR, Asp .net, Sinatra.This session focuses on the basics things needed to start building application on it.
Dethroning Grunt: Simple and Effective Builds with gulp.jsJay Harris
Grunt is king. It is the ubiquitous task runner used for most nodejs projects and has quickly expanded to conquer other software ecosystems. However, its kingdom is vulnerable. Grunt does not align well with many nodejs paradigms and is notorious for its harsh learning curve. Meet Gulp, the challenger in the taskrunner revolution. Gulp’s easy configuration produces an easy learning curve, and its alignment with nodejs paradigms eliminates the friction. Grab your ticket, your foam finger, and your team-colored face paint and witness the battle, the revolution, and the crowning of Gulp.
A quick overview of tips, tricks and code snippets for developers using Symfony and all its ecosystem, from Monolog to Doctrine. Learn how to become more productive and discover some rarely used options and features.
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013Amazon Web Services
The AWS CLI is a command line interface that allows you to control the full set of AWS services. You learn how to perform quick ad hoc service operations, and how to create rich scripts to automate your ongoing maintenance. We also share tips on getting the most out of the CLI through built-in features and complementary tools.
Keeping the frontend under control with Symfony and WebpackIgnacio Martín
Webpack tutorial with tips for Symfony users. Topics covered include: current frontend trends, setup, loaders, dev tools, optimization in production, bundle splitting and tips and tricks for using webpack with existing projects.
Symfony Munich Meetup 2016.
api-platform: the ultimate API platformStefan Adolf
Building APIs can be madness, especially if you want to do it right from day 1. Uncountable projects support you in this business but api-platform stands out. In this talk Stefan demonstrates the setup of a fully featured api-platform application by merely adding some plain doctrine entities and annotations. The result is a fully interactively documented API service (Swagger) that creates JSON-LD, JSON:API or JSON-HAL compatible inline links. Its Hydra docs enables you to scaffold fully functional frontend clients without writing any code at all, and by adding just one more composer dependency everything unfolds as GraphQL API. This talk will additionally show some demos of our special use case that we’re using api platform for and how you can secure it with JWT authentication and build custom actions and data providers in case you don’t want to use relational databases at all.
Amazon Web Services and the AWS SDK for PHP continue to put more power into the hands of PHP developers to build robust and scalable web applications. With version 2 of the SDK, developers now have an even more powerful library for interacting with AWS built on top of existing open source software like the Guzzle HTTP framework and the Symfony 2 Event Dispatcher. In this session you will learn about Amazon Web Services, how to use the AWS SDK for PHP, and how you can easily deploy and scale your applications to the cloud with AWS services, including AWS Elastic Beanstalk.
Ember.js - introduction
I have searched for Ember ppt in the internet. Got many things but not like structured... So i have just combined and made a new one..
I am just learning and not an expert. Please share your comments, so i can keep up myself..
An introduction to AWS Elastic Beanstalk, a service to help run your Java web applications on the Amazon cloud, leaving you free to focus on your app. Slides from the London Java Community meetup, 1st June 2011.
Dethroning Grunt: Simple and Effective Builds with gulp.jsJay Harris
Grunt is king. It is the ubiquitous task runner used for most nodejs projects and has quickly expanded to conquer other software ecosystems. However, its kingdom is vulnerable. Grunt does not align well with many nodejs paradigms and is notorious for its harsh learning curve. Meet Gulp, the challenger in the taskrunner revolution. Gulp’s easy configuration produces an easy learning curve, and its alignment with nodejs paradigms eliminates the friction. Grab your ticket, your foam finger, and your team-colored face paint and witness the battle, the revolution, and the crowning of Gulp.
A quick overview of tips, tricks and code snippets for developers using Symfony and all its ecosystem, from Monolog to Doctrine. Learn how to become more productive and discover some rarely used options and features.
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013Amazon Web Services
The AWS CLI is a command line interface that allows you to control the full set of AWS services. You learn how to perform quick ad hoc service operations, and how to create rich scripts to automate your ongoing maintenance. We also share tips on getting the most out of the CLI through built-in features and complementary tools.
Keeping the frontend under control with Symfony and WebpackIgnacio Martín
Webpack tutorial with tips for Symfony users. Topics covered include: current frontend trends, setup, loaders, dev tools, optimization in production, bundle splitting and tips and tricks for using webpack with existing projects.
Symfony Munich Meetup 2016.
api-platform: the ultimate API platformStefan Adolf
Building APIs can be madness, especially if you want to do it right from day 1. Uncountable projects support you in this business but api-platform stands out. In this talk Stefan demonstrates the setup of a fully featured api-platform application by merely adding some plain doctrine entities and annotations. The result is a fully interactively documented API service (Swagger) that creates JSON-LD, JSON:API or JSON-HAL compatible inline links. Its Hydra docs enables you to scaffold fully functional frontend clients without writing any code at all, and by adding just one more composer dependency everything unfolds as GraphQL API. This talk will additionally show some demos of our special use case that we’re using api platform for and how you can secure it with JWT authentication and build custom actions and data providers in case you don’t want to use relational databases at all.
Amazon Web Services and the AWS SDK for PHP continue to put more power into the hands of PHP developers to build robust and scalable web applications. With version 2 of the SDK, developers now have an even more powerful library for interacting with AWS built on top of existing open source software like the Guzzle HTTP framework and the Symfony 2 Event Dispatcher. In this session you will learn about Amazon Web Services, how to use the AWS SDK for PHP, and how you can easily deploy and scale your applications to the cloud with AWS services, including AWS Elastic Beanstalk.
Ember.js - introduction
I have searched for Ember ppt in the internet. Got many things but not like structured... So i have just combined and made a new one..
I am just learning and not an expert. Please share your comments, so i can keep up myself..
An introduction to AWS Elastic Beanstalk, a service to help run your Java web applications on the Amazon cloud, leaving you free to focus on your app. Slides from the London Java Community meetup, 1st June 2011.
Fisl 11 - Dicas de Desenvolvimento Web com RubyFabio Akita
Performance de sites não tem a ver com a linguagem usada por baixo. O impacto maior é a arquitetura. Nesta palestra falo sobre YSlow, Resque e Solr como algumas das coisas que podemos fazer para melhorar a performance/escalabilidade de aplicações web.
Web Frontend development: tools and good practices to (re)organize the chaosMatteo Papadopoulos
After my first attempt to "organize the chaos" (2012) in the structure of a front-end project, Stefano Verna (@steffoz) and I, have tried to bring together a number of tools and conventions to deal with front-end development in a way that could be understandable and maintainable, over the time, by a whole team.
This presentation has been performed, for the first time, during the Ruby-Day-2014 in Venice, Italy.
Here the video of the speech (italian): https://www.youtube.com/watch?v=fUJOJY_yVXg&index=6&list=PL5ImBN21eKvbQ6kH6WCAqj1QqgusGsiO0
Sprockets is an easy solution to managing large JavaScript codebases by letting you structure it, bundle it with related assets, and consolidate it as one single file, with pre-baked command-line tooling, CGI front and Rails plugin. It's a framework-agnostic open-source solution that makes for great serving performance while helping you structure and manage your codebase better.
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass and ERB.
Consegi 2010 - Dicas de Desenvolvimento Web com RubyFabio Akita
Esta é a palestra que dei no Consegi 2010 em Brasília. Sobre dicas gerais sobre web, em particular implementando com Ruby on Rails. YSlow, Full Text Search e Tarefas Assíncronas.
FOXX - a Javascript application framework on top of ArangoDBArangoDB Database
Foxx allows you to build APIs directly on top of the database ArangoDB in Javascript and therefore skip the middleman (Rails, Django, Symfony or whatever your favorite web framework is). Foxx is designed with simplicity and the specific use case of modern client-side MVC frameworks in mind.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
2. Table of Contents
01 The pain of assets in 3.0
02 Asset Pipeline to the rescue
03 New Stuff
04 Deployment story
Asset Pipeline !"#$%&'(&)*+%,
3. Bad Organization
stylesheets
ROOT/public javascripts
images
Asset Pipeline !"#$%&'(&)*+%,
One of the big pains in how Rails pre 3.1 handles assets is organizational. You have one
place to put all your assets, one place to put stylesheets, one place to put javascripts, and
one place to put images. But what ends up happening?
4. application code
third party code
Asset Pipeline !"#$%&'(&)*+%,
Big Ass Folders
Mixing 3rd party code
How do you update?
Mixing abstractions
be like extracting rails into your project
5. lowercase d dependencies
‣ application.html.erb
<%= stylesheet_link_tag 'default',
'index' %>
<%= javascript_include_tag 'jquery',
'rails', 'application' %>
Asset Pipeline !"#$%&'(&)*+%,
ad hoc dependency declaration
6. Table of Contents
01 The pain of assets in 3.0
02 Asset Pipeline to the rescue
03 New Stuff
04 Deployment story
Asset Pipeline !"#$%&'(&)*+%,
7. Assets as First Class Citizens
‣ Better Opinions
‣ Empty Files and Folders
‣ Generators
‣ Capital-D Dependencies
Asset Pipeline !"#$%&'(&)*+%,
8. Better Opinions
app/assets stylesheets
lib/assets javascripts
vendor/assets images
Asset Pipeline !"#$%&'(&)*+%,
Now assets are in 3 places.
app/assets holds the code you write for this specific application
lib/assets holds the generic library code you write for this application
vendor/assets holds third party code
9. app/assets
localhost:3000/assets/application.js
Asset Pipeline !"#$%&'(&)*+%,
Now, when you generate a new rails 3.1 app, you get two assets, application.js and
application.css in app/assets.
And now that 3.1 ships with jQuery by default, where is that?
11. vendor/assets
localhost:3000/assets/ie6_screen.css
Asset Pipeline !"#$%&'(&)*+%,
3rd party
12. Capital-D Dependencies
‣ app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
sprockets
Asset Pipeline !"#$%&'(&)*+%,
looks like ruby require
require inlines the code when application.js is served, in order.
But where are these files?
13. Capital-D Dependencies
‣ Gemfile
gem 'jquery-rails'
https://github.com/rails/jquery-rails
//= require jquery
//= require jquery_ujs
Asset Pipeline !"#$%&'(&)*+%,
So we’ve declared our dependency on jquery and jquery_ujs in our application.js file, but
where are these files?
Well, now gems can have their own assets, and rails 3.1 ships with this jquery-rails gem in
your Gemfile, which provides jquery and jquery_ujs files necessary to work with the
framework.
Notice the familiar layout for assets, vendor/assets/javascripts.
14. Don’t like jQuery?
‣ Gemfile
# gem 'jquery-rails'
gem 'prototype'
‣ app/assets/javascripts/application.js
//= require prototype
Asset Pipeline !"#$%&'(&)*+%,
Now its also very easy to switch back to prototype, or some other javascript library.
15. Including assets
‣ application.html.erb
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'application' %>
(function( window, undefined ) {
// all of jquery here
})( jQuery );
(function() {
// application code here
}).call(this);
Asset Pipeline !"#$%&'(&)*+%,
In your application.html.erb, you would define which stylesheets and javascripts you would
need.
16. Generators
‣ rails generate assets Post
‣ rails generate scaffold User
Asset Pipeline !"#$%&'(&)*+%,
Another way rails 3.1 makes assets into a first class citizen is through generators.
So now that we have a place to put resource specific asset code, how do we include these in
our app?
17. Dependency Directives
‣ app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require_tree .
require app/assets/javascripts/**/*
Asset Pipeline !"#$%&'(&)*+%,
require_tree will require all files in javascripts, and any nested folders.
18. More Directives
‣ require
‣ require_tree .
‣ require_self
‣ require_directory ‘posts’
‣ include ‘file’
‣ depend_on ‘file.png’
Asset Pipeline !"#$%&'(&)*+%,
require_self takes the code from the current file and inlines it in place, helps when requiring
dependencies after require_self that depend on the current file
require_directory is similar to require_tree, but it wont traverse nested directories
include works like require, but will always insert the content even if its been required already
depend_on will declare a dependency that doesn’t get required, but is used for caching
purposes * will go into caching stuff more later
19. Table of Contents
01 The pain of assets in 3.0
02 Asset Pipeline to the rescue
03 New Stuff
04 Deployment story
Asset Pipeline !"#$%&'(&)*+%,
20. CoffeeScript and Sass
‣ Gemfile
group :assets do
gem 'sass-rails'
gem 'coffee-script'
end
Default in 3.1
Asset Pipeline !"#$%&'(&)*+%,
The asset group is required by default in development and test environments, but not in
production.
21. CoffeeScript and Sass
‣ app/assets/javascripts/application.js.coffee
jQuery ($) ->
$('.truncate-more-link').live 'click', (e) ->
$this = $ this
# do more stuff here
‣ app/assets/stylesheets/application.css.scss
$blue: #3bbfce;
$margin: 16px;
.content-navigation {
border-color: $blue;
color: darken($blue, 9%);
}
Asset Pipeline !"#$%&'(&)*+%,
Before they are served to the browser, the asset pipeline passes these files through their
respective preprocessors.
22. Generators
‣ rails generate assets Review
‣ rails generate scaffold Comment
Asset Pipeline !"#$%&'(&)*+%,
Now generators work with coffeescript and sass and generate the appropriate files
23. Chaining Preprocessors
‣ app/assets/stylesheets/application.css.scss.erb
$blue: #3bbfce
$margin: 16px
.content-navigation
background: url(<%= asset_path(‘background.png’) %>)
color: darken($blue, 9%)
$blue: #3bbfce
$margin: 16px
.content-navigation
background: url(/assets/background-374e12d5b46ffa3d2f92a11dbae9b06a.png)
color: darken($blue, 9%)
Asset Pipeline !"#$%&'(&)*+%,
Before they are served to the browser, the asset pipeline passes these files through their
respective preprocessors.
25. Table of Contents
01 The pain of assets in 3.0
02 Asset Pipeline to the rescue
03 New Stuff
04 Deployment story
Asset Pipeline !"#$%&'(&)*+%,
26. rake assets:precompile
‣ app/assets/stylesheets/application.css.scss.erb
$blue: #3bbfce
.content-navigation
background: url(<%= asset_path(‘background.png’) %>)
color: darken($blue, 9%)
‣ public/assets/application-e317be572968fcf8892b5c767f776d82.css
.content-navigation {
background: url(/assets/background-92a96fe5e422523a2de56c9f0defe51b.png);
color: #2ca2af;
}
Asset Pipeline !"#$%&'(&)*+%,
All assets get compiled into public/assets, where they can easily be served by your webserver
or a CDN.
27. Precompile
‣ config/deploy.rb
before :"deploy:symlink", :"deploy:assets";
desc "Compile assets"
task :assets do
run "cd #{release_path}; RAILS_ENV=#{rails_env} bundle exec
rake assets:precompile"
end
Asset Pipeline !"#$%&'(&)*+%,
28. Caching
<script src="/javascripts/application.js?1292365692">
</script>
<script src="/assets/
application-374e12d5b46ffa3d2f92a11dbae9b06a.js">
</script>
depend_on
Asset Pipeline !"#$%&'(&)*+%,
Rails used to append a deploy timestamp to all asset paths to reset the cache.
With the asset pipeline, there is no deploy timestamp. Instead, rails will include an MD5 hash
of the contents of the file in the filename itself.
So now the cache stays fresh until the file actually changes, so if you are deploying a lot, but
not changing the asset files, then you should see some nice performance improvements.
29. Compression
‣ config/environments/production.rb
# Compress both stylesheets and JavaScripts
config.assets.compress = true
gem 'uglifier' requires js runtime
Asset Pipeline !"#$%&'(&)*+%,
Both Mac OS X and Windows ship with javascript runtimes
If you are deploying to heroku you can use therubyracer-heroku, which includes a build of
nodejs specifically for heroku, but it will bloat your heroku slug size by 30MB
30. Rails 3.1 Asset Pipeline
Any questions?
Asset Pipeline !"#$%&'(&)*+%,