Skip to content

Instantly share code, notes, and snippets.

View gaaady's full-sized avatar

Gady gaaady

  • Opinya
  • Israel
View GitHub Profile
@ryanb
ryanb / index.js.erb
Created December 16, 2011 23:22
Infinite scrolling solution covered in revised episode #114: http://railscasts.com/episodes/114-endless-page-revised
$('#products').append('<%= j render(@products) %>');
<% if @products.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@products) %>');
<% else %>
$('.pagination').remove();
<% end %>
@tcocca
tcocca / FollowsController.rb
Created March 9, 2011 21:55
sample of how to use acts_as_follower with rails3 and ajax
class FollowsController < ApplicationController
def create
@user = User.find(params[:user_id])
current_user.follow(@user)
end
def destroy
@user = User.find(params[:user_id])
current_user.stop_following(@user)
@daz
daz / gist:818065
Last active September 24, 2015 22:18
Google Analytics Rails helper
# <%= google_analytics 'UA-XXXXXX-XX' %>
# </body>
# application_helper.rb
module ApplicationHelper
def google_analytics(id)
content_tag :script, :type => 'text/javascript' do
"var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#{id}']);