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
namespace :routes do | |
desc "Writes doc/routes.html. Requires Graphviz (dot)" | |
task :visualizer => :environment do | |
File.open(Rails.root.join('doc', 'routes.html'), 'wb') do |f| | |
f.write Rails.application.routes.router.visualizer | |
end | |
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
require "resque" | |
require "resque/failure/multiple" | |
require "resque/failure/redis" | |
# Configure Resque connection from config/redis.yml. This file should look | |
# something like: | |
# development: localhost:6379 | |
# test: localhost:6379:15 | |
# production: localhost:6379 | |
Resque.redis = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env] |
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
# @topic = Topic.new(params[:topic]) | |
# @topic.this_user = current_user | |
class Topic < ActiveRecord::Base | |
belongs_to :user | |
attr_accessor :this_user | |
def validate_on_update | |
# Make sure that this_user is an instance of User, otherwise just use the id | |
errors.add(:user, "Only the topic creator can update the topic") if user_id != this_user.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 Array | |
def splice(start, len, *replace) | |
self[start, len] = replace | |
self | |
end | |
end | |
ruby-1.8.7-p352 :008 > initial_array = [:a, :c, :h, :g, :t, :m] | |
=> [:a, :c, :h, :g, :t, :m] | |
ruby-1.8.7-p352 :009 > initial_array.splice(2, 2, :test) |
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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
layout Proc.new { |controller| controller.request.xhr? ? 'ajax' : 'test' } | |
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
source "http://rubygems.org" | |
# Framework | |
gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-1-stable" | |
gem "mysql2", :git => "git://github.com/brianmario/mysql2.git" | |
# Asset template engines | |
gem "sass"#, :git => "git://github.com/nex3/sass.git" | |
gem "sass-rails", :git => "git://github.com/rails/sass-rails.git" | |
gem "coffee-script"#, :git => "git://github.com/jashkenas/coffee-script.git" |
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 'omniauth/core' | |
require 'digest/md5' | |
require 'rest-client' | |
require 'multi_json' | |
module OmniAuth | |
module Strategies | |
class Lastfm | |
include OmniAuth::Strategy |
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 Task < ActiveRecord::Base | |
belongs_to :category | |
belongs_to :project | |
validates_presence_of :project_id, :category_id | |
validates_with OvertimeValidator | |
scope :of_date, lambda { |date| where(:date => date) } | |
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
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<string name="app_name">AudioBox</string> | |
<string name="app_desc">Official AudioBox.fm cloud player for Android</string> | |
<string name="username_label">Email</string> | |
<string name="password_label">Password</string> | |
<string name="save_button_label">Save</string> | |
<string name="config_username">username</string> |