Skip to content

Instantly share code, notes, and snippets.

View msievers's full-sized avatar

Michael Sievers msievers

View GitHub Profile
@riyad
riyad / application_helper.rb
Created May 23, 2012 13:45
Render Rails assets to string
module ApplicationHelper
# thanks to http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/
# you may need to change the owner of the tmp/cache/* directories to the web servers user
# e.g. for Debian systems: `chown -R www-data:www-data tmp/cache/*`
def render_asset(asset)
Conferator::Application.assets.find_asset(asset).body.html_safe
end
end
@bonyiii
bonyiii / gist:2158289
Created March 22, 2012 13:14
Rails ajax link_to remote with put, post
http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/
http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000514
http://stackoverflow.com/questions/5241213/rails-session-is-blank-when-using-http-put
Key thing is to add form_authenticity_token to path param as a query_string
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
<%= link_to 'Reset', null_counter_model_path(model, :authenticity_token => form_authenticity_token), :confirm => 'Are you sure?', :method => :put, :remote => true %>