This file contains 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
ActiveRecord::Base.send :include, Spock::Base::Filterable | |
module Spock | |
module Base | |
module Filterable | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
This file contains 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
# Usage | |
# @assets = Asset.my_filter(params[:filter]).public.all # works like a charm | |
# @assets = @account.assets.my_filter(params[:filter]).public.paginate({ | |
# :page => (params[:page] || 1) | |
# }) # works BUT (ofc) does not adhere to the @account scope | |
# | |
# initializer | |
ActiveRecord::Base.send :include, Spock::Base::Filterable |
This file contains 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 Spock | |
module Base | |
module Filterable | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def filter(f) |
This file contains 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
--- | |
cwd: /home/unicef/staging/current | |
port: "9070" | |
user: unicef | |
group: mongrel | |
environment: staging | |
address: 127.0.0.1 | |
pid_file: log/mongrel.pid | |
servers: 2 |
This file contains 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 File.dirname(__FILE__) + '/../test_helper' | |
class MashAppTest < ActiveSupport::TestCase | |
context "A MashApp instance" do | |
setup do | |
@mash_app = Factory.create(:mash_app) | |
end | |
This file contains 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
# Allow the metal piece to run in isolation | |
require File.expand_path('../../../config/environment', __FILE__) unless defined?(Rails) | |
class AutoComplete | |
def self.call(env) | |
if env["PATH_INFO"] =~ /^\/auto_complete\/tags/ | |
params = Rack::Request.new(env).params | |
sql = "SELECT name | |
FROM tags | |
WHERE name LIKE #{ActiveRecord::Base.connection.quote(params['q']+'%')} |
This file contains 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
apps_controller: | |
def search | |
@query = params[:query] | |
@search = App.search(@query) | |
respond_with(@search) | |
end | |
app.rb: | |
class << self |
This file contains 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 $search = $('<input type="search">'), | |
$button = $('<button>Search</button>'), | |
$result_container = $('<div id="app_search_result" />'), | |
$app_list = $('#apps'); | |
var $app_form = $(this).after($search, $button, $result_container).detach(); | |
$search.data('search_context', 'local'); | |
$search |
This file contains 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
$.fn.appForm = function() { | |
return this.each(function() { | |
var $search = $('<input type="search">'), | |
$button = $('<button>Search</button>'), | |
$result_container = $('<div id="app_search_result" />'), | |
$app_list = $('#apps'); | |
var $app_form = $(this).after($search, $button, $result_container).detach(); | |
$search.data('search_context', 'local'); |
This file contains 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
# Setting for open or closed tags by default | |
module ActionView::Helpers | |
module TagHelper | |
mattr_accessor :default_tags_to_open | |
self.default_tags_to_open = false | |
def tag(name, options = nil, open = ActionView::Helpers::TagHelper.default_tags_to_open, escape = true) | |
"<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe | |
end |
OlderNewer