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
# Use like so: | |
# @key_i_need = @event.seek :coordinator, :api_license, :key | |
class Hash | |
def seek(*_keys_) | |
last_level = self | |
sought_value = nil | |
_keys_.each_with_index do |_key_, _idx_| | |
if last_level.is_a?(Hash) && last_level.has_key?(_key_) | |
if _idx_ + 1 == _keys_.length |
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 'minitest_helper' | |
require 'helpers/application_helper' | |
describe ApplicationHelper do | |
before :all do | |
@helper = Struct.new(:request).new #Create an empty request method so it can be stubbed | |
@helper.extend(ApplicationHelper) | |
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
# 1. Excerpt of Photo and User model | |
# Photos can belong to Cities and Districts, and users can browse Cities and | |
# Districts to see the photos in them. When a user uploads a photo I really want | |
# them to tell me where the photo came from. | |
# Also, Users can be from a City and District. This is not currently used for very | |
# much, but gives me a path to add location-enhanced results for other stuff in the | |
# future. |
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 PhotosController < ApplicationController | |
before_filter :authenticate_user!, :except => [:index, :show] | |
impressionist :actions=>[:show] | |
respond_to :html, :json | |
def index | |
@search = Photo.search(params[:search]) | |
@search.meta_sort ||= 'created_at.desc' | |
@photos = @search.page(params[:page]).per(20) | |
respond_with @photos |
NewerOlder