Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View iwasrobbed's full-sized avatar
:shipit:
"1 billion years".Save()

rob phillips iwasrobbed

:shipit:
"1 billion years".Save()
View GitHub Profile
def link_to_with_highlight(name, options = {}, html_options = {}) # same sig as #link_to
html_options.merge!({ :class => 'active' }) if current_page?(options)
link_to(name, options, html_options)
end
# app/views/layout/application.rb
<html>
<head>
<%= yield :head %>
...
# app/views/foobars/index.html.erb
<% content_for :head do %>
<script type='text/javascript'>
<table>
<%= render :partial => 'foo_row', :collection => @foobars %>
</table>
# _foo_row.html.erb
<tr>
<td>
<%= foobar.name %>
</td>
#config/initializers/requires.rb
Dir[File.join(Rails.root, 'lib', '*.rb')].each do |f|
require f
end
= link_to "Sign out", signout_path,
:method => :delete,
:class => "nohover tl light"
= link_to "Link name",
{ :controller => 'controller_name', :action => 'action_name' },
:class => 'someclass'
root /(.:format) {:controller=>"users", :action=>"new"}
sessions POST /sessions(.:format) {:action=>"create", :controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new", :controller=>"sessions"}
session DELETE /sessions/:id(.:format) {:action=>"destroy", :controller=>"sessions"}
user_favorite GET /users/:user_id/favorites/:id(.:format) {:action=>"show", :controller=>"favorites"}
PUT /users/:user_id/favorites/:id(.:format) {:action=>"update", :controller=>"favorites"}
user_profile GET /users/:user_id/profile/:id(.:format) {:action=>"show", :controller=>"profile"}
PUT /users/:user_id/profile/:id(.:format) {:action=>"update", :controller=>"profile"}
@iwasrobbed
iwasrobbed / gist:906235
Created April 6, 2011 18:37
Infinite scrolling modified for ajax
function kickOffAjax(){
// we dont want to fire the ajax multiple times
opts.isDuringAjax = true;
// show the loading message quickly
// then hide the previous/next links after we're
// sure the loading message was visible
props.loadingMsg.appendTo( opts.loadMsgSelector ).show(opts.loadingMsgRevealSpeed, function(){
$( opts.navSelector ).hide();
class ImportController << ApplicationController
require 'net/http'
require 'net/https'
require 'uri'
#THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE.
def authenticate
# initiate authentication w/ gmail
# create url with url-encoded params to initiate connection with contacts api
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" secure="false" />
</cross-domain-policy>