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 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) |
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
#!/bin/sh -e | |
# chkconfig: 345 99 1 | |
# description: Tomcat6 service | |
# processname: java | |
# Get LSB functions | |
. /lib/lsb/init-functions | |
export JAVA_HOME=/usr | |
export TOMCAT_USER=solr |
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
SELECT leads.id, | |
(SELECT COUNT(*) FROM searches WHERE lead_id = leads.id) AS searches_count, | |
(SELECT COUNT(*) FROM rental_searches WHERE lead_id = leads.id) AS rental_searches_count, | |
COALESCE((searches_count + rental_searches_count), 0) as total | |
FROM leads | |
WHERE leads.id = 35 | |
# Unknown column 'searches_count' in 'field list' |
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 SearchReport < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :report, :polymorphic => true | |
end | |
class User < ActiveRecord::Base | |
... | |
has_many :search_reports |
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 SearchDateRange < ActiveRecord::Base | |
validates_presence_of :name | |
validates_presence_of :sort_order | |
def range_start_end | |
time = Time.zone.now | |
case self.name | |
when 'Today' | |
[time.beginning_of_day, time.end_of_day] |
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
#file: app/themes/blue/mixins/blue_users_controller_mixin.rb | |
module BlueUsersControllerMixin | |
def blue_show | |
#themed_show method here | |
end | |
end | |
# app/controllers/users_controller.rb |
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 ThemeMixin | |
=begin | |
# Rails only w/ alias_method_chain | |
def self.included(base) | |
base.alias_method_chain(:base_method, :override) | |
end | |
def base_method_with_override | |
"theme index" |
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
attr_accessor :features_as_hash | |
def method_missing(method_name, *args, &block) | |
name = method_name.to_s | |
if self.respond_to?(name) | |
super | |
elsif features_hash.has_key?(name) | |
return features_hash[name] | |
else | |
logger.debug("Attribute #{name} on property #{self.id} does not exist") |
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
map.resources :users do |user| | |
user.resources :daily_searches | |
end | |
map.namespace :admin do |admin| | |
admin.resources :leads do |lead| | |
lead.resources :daily_searches | |
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
def following_by_type(followable_type, options={}) | |
follows = followable_type.constantize. | |
includes(:followings). | |
where( | |
"follows.follower_id = ? AND follows.follower_type = ? AND follows.followable_type = ? AND blocked = ?", | |
self.id, parent_class_name(self), followable_type, false | |
) | |
if options.has_key?(:limit) | |
return follows.limit(options[:limit]) | |
end |