Skip to content

Instantly share code, notes, and snippets.

class Response < ActiveRecord::Base
serialize :answers
end
# rails c
irb(main):022:0> [{"answers" => {"foo" => "bar"}}].map {|response| Response.new(response)}
=> [#<Response id: nil, answers: {"foo"=>"bar"}, created_at: nil, updated_at: nil, questionnaire_id: nil>]
Hooray!
{
data = {
locations = (
{
accuracy = 65;
latitude = "53.47403263168288";
longitude = "-2.252531799015698";
timestamp = "20120425T214228.426";
},
{
* Off the shelf solutions like Yammer, Ning and Grou.ps
* Pros:
* Faster deployment time means may be cheaper in long term
* Easily spans multiple office locations
* Can login anywhere, even from mobile devices not connected to the company Wifi
* Cons:
* Subject to terms and conditions with published content
* Goodbye social network if the company goes under
* Changes beyong scope of service functionality may be difficult
* Ongoing monthly cost
* Ning - "Plus"
* £16.95/mo
* Up to 10k members
* 10GB storage
* Grou.ps - "Gold"
* $19.95/mo
* Up to 1k members
* 10GB Storage
* Yammer - "Premium Group"
* $79/mo
@wooly
wooly / nice_image_input.rb
Created June 6, 2013 15:00
Nicer Image uploads for simple_form with jasny bootstrap
# app/inputs/nice_image_input.rb
class NiceImageInput < SimpleForm::Inputs::Base
def input
template.content_tag(:div, class: "fileupload fileupload-new", data: { provides: "fileupload" }) do
template.concat(template.content_tag(:div, class: "fileupload-new thumbnail", style: "width: 100px; height: 100px; margin-right: 4px;") do
template.image_tag(object.image.url(:thumb), class: "input-prepend", size:"100x100")
end)
template.concat(template.content_tag(:div, nil, class: "fileupload-preview fileupload-exists thumbnail", style: "width: 100px; height: 100px; margin-right: 4px;"))
template.concat(template.content_tag(:span, class:"btn btn-file") do
template.concat(template.content_tag(:span, "Select image", class: "fileupload-new"))
class Membership
has_many :profiles
belongs_to :current_profile
end
class MembershipProfile
belongs_to :team
belongs_to :membership
end
#app/models/team.rb
def membership
Membership.joins(:current_profile).where('membership_profiles.team_id = ?', id)
end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).