Skip to content

@ethagnawl /Gemfile
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Conditionally Execute JavaScript in the Asset Pipeline
class ApplicationController < ActionController::Base
before_filter :set_gon
# ...
private
def set_gon
gon.page = "#{params[:controller]}_#{params[:action]}"
end
end
end
if gon.page is 'foo_bar'
$ ->
alert "Top o' the mornin' to ya'!"
if gon.page is 'foo_baz'
$ ->
alert "... and Bob's your uncle!"
# https://github.com/gazay/gon
gem 'gon'
!!! 5
%html
%body
%h1 Foo
= yield
= include_gon
= javascript_include_tag 'application'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.