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 you have a filter which is used in a lot of controllers and thus requires constant mocking | |
# implicitly skip before_filter in all controllers: | |
# in spec_helper.rb | |
config.before(:each) do | |
if defined? controller and not example.options[:with_before_filter] == :my_filter | |
controller.class.skip_before_filter :my_filter | |
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 self.within_distance_from(*args) | |
return Place.within_distance_from_place args[0], args[1] if args.length == 2 | |
return Place.within_distance_from_point args[0], args[1], args[2] if args.length == 3 | |
raise ArgumentError, 'Call with either a Place or latitude, longitude; and distance' | |
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
class PlaceEventsController < ApplicationController | |
before_filter :authenticate_user! | |
before_filter :weeks_ago_range | |
respond_to :json, only: [:edit, :update] | |
[snip edit and index] | |
def update | |
place_event = current_user.place_events.find params[: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
# you have your list of the user's posts, | |
# these are just in whatever order your DB gets them, which is probably (but not guaranteed) to be ordered by the post id: | |
@posts = user.posts | |
@posts.map { |p| [p.id, p.category_id] } # [[1,3], [2,5], [3,3], [4,1]] | |
# you can specify that you'd like the order explicitly like this, | |
# here we ask for them ASCending, you have to pick one, but it probably doesn't matter in your case: | |
@posts = user.posts.order('category_id ASC') | |
@posts.map { |p| [p.id, p.category_id] } # [[4,1], [3,3], [1,3], [2,5]] |
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
node do | |
{ name: current_user.first_name, | |
visited_number: @all_places.length, | |
visited_period: Time.now - current_user.created_at } | |
end | |
child PlaceDecorator.decorate_collection(@all_places) => :table do | |
attributes :id, :name | |
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
# config/routes.rb | |
resources :places, only: [:index, :edit, :update], constraints: {format: :json} do | |
collection do | |
get 'map' | |
end | |
# app/controllers/places_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
<!-- Running command: | |
curl -o latest.dump `heroku pgbackups:url --app xxxxx` | |
At 100% we get: --> | |
<Error><Code>AccessDenied</Code><Message>Request has expired</Message><RequestId>xxxxxxx</RequestId><Expires>2013-03-21T16:02:26Z</Expires><HostId>xxxxxxx</HostId><ServerTime>2013-03-21T16:50:38Z</ServerTime></Error> |
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
34.442688693689824,-113.53830101755034 | |
34.33576843364106,-113.42973400738283 | |
34.44648524918964,-113.52317003164038 | |
34.41614244624507,-113.42110221380793 | |
34.443154610235155,-113.49498783458732 | |
34.43219600146056,-113.43444706591943 | |
34.36054463655045,-113.53565715125131 | |
34.427160925658754,-113.47398007995909 | |
34.43880963756491,-113.43854457484196 | |
34.37758904544772,-113.51267759234292 |
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
exports.routes = function() { | |
this.get('/', function() { | |
var users = db.collection('users'); | |
this.res.setHeader("Content-Type", 'text/html'); | |
this.res.writeHead(200, {}); | |
var that = this; | |
var stream = users.find().forEach(function(err, userDoc) { | |
if(userDoc) { |