Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar

Philip Arndt parndt

View GitHub Profile
@parndt
parndt / application.rb
Created May 30, 2011 04:53
config/application.rb hooks for Dragonfly in Refinery CMS
# Place this in the config block on config/application.rb of your Rails application.
# Override where dragonfly keeps your images and its url format
config.to_prepare do
::Dragonfly[:images].configure do |c|
c.datastore.root_path = Rails.root.join('public', 'assets', 'images').to_s
c.url_format = '/assets/images/:job/:basename.:format'
end
end
@parndt
parndt / gist:1011435
Created June 7, 2011 00:32
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@parndt
parndt / _menu_branch.html.erb
Created August 19, 2011 04:59 — forked from michaelward82/_menu_branch.html.erb
Limit menu rendering in Refinery CMS
<%
if !!local_assigns[:apply_css] and (classes = menu_branch_css(local_assigns)).any?
css = "class='#{classes.join(' ')}'".html_safe
end
# dom_id DEPRECATED: REMOVE AT 1.1, serves no purpose same with css attributes 'first' and 'last'
dom_id = "id='item_#{menu_branch_counter}'".html_safe if menu_branch.parent_id.nil?
-%>
<li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
<%= link_to menu_branch.title, menu_branch.url -%>
<% if ( (children = menu_branch.children unless hide_children).present? &&
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: activeresource requires activesupport (= 3.0.10), activemodel (= 3.0.10); activerecord requires activesupport (= 3.0.10), activemodel (= 3.0.10), arel (~> 2.0.10); rails requires activesupport (= 3.0.10); railties requires activesupport (= 3.0.10); globalize3 requires activemodel (>= 3.0.0); mail requires activesupport (>= 2.3.6), i18n (>= 0.4.0); actionpack requires activesupport (= 3.0.10), activemodel (= 3.0.10), builder (~> 2.1.2), i18n (~> 0.5.0)
@parndt
parndt / .gitconfig
Created September 15, 2011 21:55
What I use in my ~/.gitconfig
[user]
name = Your Name
email = [email protected]
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
@parndt
parndt / gist:1346958
Created November 8, 2011 03:59
Get up and running with ruby
0: install open source gcc "standalone" using OSX installer:
https://github.com/kennethreitz/osx-gcc-installer
1: install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
2: install rvm
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
MAKE SURE you follow the instructions about putting stuff in ~/.bashrc or ~/.bash_profile
@parndt
parndt / gist:1425251
Created December 2, 2011 23:04
Routing example
$ rake routes | grep pe
refinery_people GET /people(.:format) {:action=>"index", :controller=>"refinery/people"}
refinery_person GET /people/:id(.:format) {:action=>"show", :controller=>"refinery/people"}
update_positions_refinery_admin_people POST /refinery/people/update_positions(.:format) {:action=>"update_positions", :controller=>"refinery/admin/people"}
refinery_admin_people GET /refinery/people(.:format) {:action=>"index", :controller=>"refinery/admin/people"}
POST /refinery/people(.:format) {:action=>"create", :controller=>"refinery/admin/people"}
new_refinery_admin_person GET /refinery/people/new(.:format) {:action=>"new", :controller=>"refinery/admin/people"}
edit_refinery_admin_person GET
<%= render 'shared/menu', :roots => @menu_pages.select{|p| p.parent_id == @page.id} %>
@parndt
parndt / gist:1447722
Created December 8, 2011 17:29
Install edge Refinery CMS
gem install rails
rails new my_application_name -m https://raw.github.com/resolve/refinerycms/master/templates/refinery/edge.rb
cd my_application_name
rails server
@parndt
parndt / gist:1488486
Created December 16, 2011 23:22
Assets on Heroku in config/application.rb
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
# Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
Bundler.require(:default, :assets, Rails.env)
end