Skip to content

Instantly share code, notes, and snippets.

View abhishek0's full-sized avatar

Abhishek Sharma abhishek0

  • Snapstick Inc.
View GitHub Profile
raw_data = JSON.parse(response.body)
@data = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
raw_data.each do |u|
# u["id"] actually prints u itself??
id = u["id"], name = u["first_name"], l = u["locality"], c = u["city"]
@data[id]["first_name"] = name
@data[id]["locality"] = l
@data[id]["city"] = c
@data[id][u["status"]] = u["count"]
end
object @user
attributes *(@user.class.column_names - %w{id user_type parent_id stamp_id created_at updated_at password_digest access_token})
child :stamp => :contact do |stamp|
glue(stamp.contact) { attributes :first_name, :last_name, :email, :contact1, :contact2 }
end
node(:status) {|user| user.stamp.status }
@abhishek0
abhishek0 / application_helper.rb
Created September 21, 2013 14:41
Mailer view using helper throws error
module ApplicationHelper
def readable_bool val
val ? "Yes" : "No"
end
end