Skip to content

Instantly share code, notes, and snippets.

View SeanRoberts's full-sized avatar

Sean Roberts SeanRoberts

View GitHub Profile
class DrugFinder
attr_accessor :user, :scope
def initialize(user, scope = Drug.all)
@user = user
@scope = scope
end
def drugs
if user.is_admin?
drugs_for_admin
class Tenon::ProfileSpecificResourcesController < Tenon::ResourcesController
before_filter :authorize_site
def index
params[:page] = 1 if params[:page].to_i == 0
respond_to do |format|
format.html
format.json do
self.collection = current_profile.send(plural_name)
self.collection = collection.where(search_args) if params[:q]
_subscribeToEvents: ->
PubSub.subscribe 'mailChimp:loading', (e) ->
@setState(loading: true) if e.submitter == this
PubSub.subscribe 'mailChimp:done', (e) ->
@setState(loading: false) if e.submitter == this
PubSub.subscribe 'mailChimp:success', (e) ->
@setState(successMsg: e.msg, errorMsg: null) if e.submitter == this
.embed-container
- if obj.external_video_url.downcase.match('youtube')
%iframe.external-video{ :frameborder => 0, :allowfullscreen => true, :src => "//www.youtube.com/embed/#{youtube_video_id_from_url(obj.external_video_url)}?rel=0" }
- elsif obj.external_video_url.downcase.match('vimeo')
%iframe.external-video{ frameborder: 0, webkitallowfullscreen: true, mozallowfullscreen: true, allowfullscreen: true, src: "//player.vimeo.com/video/#{vimeo_video_id_from_url(obj.external_video_url)}?color=#{current_site.brand_color.gsub('#', '')}&title=0&byline=0&portrait=0"}
# The CSS
.embed-container {
position: relative;
padding-bottom: 56.25%;
{"errors":"{\"name\":[\"can't be blank\"],\"email\":[\"can't be blank\"],\"base\":[\"You are not human (according to reCAPTCHA).\"]}"}
# For more information see: http://emberjs.com/guides/routing/
OH.Router.map ()->
@resource 'listings', path: '/', ->
@route 'show', path: '/listings/:id'
@resource 'itinerary', path: '/itinerary/:id'
@resource 'realtors', path: '/realtors', ->
@route 'show', path: ':id'
actions:
search: ->
@store
.find('realtor', { name: @get('name'), city: @get('city') })
.then (result) =>
@set('model', result)
@set('meta', result.get('meta'))
actions:
search: ->
find = @store.find('realtor', { name: @get('name'), city: @get('city') })
@set('model', find)
OH.RealtorsIndexRoute = Ember.Route.extend
model: (params) ->
params.page ||= 1
@store.find('realtor', { page: params.page })
setupController: (controller) ->
$.get('/api/v1/realtors/cities.json').then (data) =>
controller.set('cities', data.cities)
# Model
OH.Itinerary = DS.Model.extend
uniqueKey: DS.attr('string')
listings: DS.hasMany('listing')
remove: (listing) ->
if confirm("Remove #{listing.get('address1')} from your itinerary?")
@get('listings').removeObject(listing)
$.ajax
url: "/api/v1/itinerary_listings/#{@get('uniqueKey')}.json"