This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::Routing::Routes.draw do |map| | |
map.with_options :controller => "info" do |info| | |
%w[action1 action2 whatever yada1 yada2 yada3].each do |action| | |
info.send(action, action, :action => action) | |
end | |
info.home "/" | |
info.root | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# steroids_on_steroids | |
class Steroids | |
def initialize | |
Steroids.new | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in config/routes.rb | |
map.blog "/blog", :controller => "blog" | |
map.blog "/blog/:id", :controller => "blog", :action => "show", :id => id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Thing | |
attr_accessor :name, :age | |
end | |
class Thing < Struct.new(:name, :age) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def ensure_a | |
self.is_a?(Array) ? self : [self] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AuthenticatedSystem | |
protected | |
# Returns true or false if the user is logged in. | |
# Preloads @current_user with the user model if they're logged in. | |
def logged_in? | |
!!current_user | |
end | |
# Accesses the current user from the session. | |
# Future calls avoid the database because nil is not equal to false. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comatose.configure do |config| | |
config.admin_includes << :your_authentication_module | |
config.admin_authorization = :your_auth_before_filter_method | |
config.admin_get_root_page do | |
if current_user.role == 'troop_leader' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'httparty' | |
class CalorieKing | |
include HTTParty | |
basic_auth '84294d7ae4454189bf2a3ebc37a0e421', '' | |
base_uri 'http://foodsearch1.webservices.calorieking.com/rest' | |
def self.search(term) | |
get("/search/#{term}") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your application-specific JavaScript functions and classes here | |
// This file is automatically included by javascript_include_tag :defaults | |
var $j = jQuery.noConflict(); | |
jQuery(document).ready(function($){ | |
var rowGuid = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $j = jQuery.noConflict(); | |
jQuery(document).ready(function($){ | |
$("#id_of_my_textarea").markItUp(nameOfSettings); | |
}); | |
jQuery.ajaxSetup({ | |
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", |