Skip to content

Instantly share code, notes, and snippets.

export PS1='\[\033[38m\]\u\[\033[32m\] \w \[\033[1;33m\]`~/.rvm/bin/rvm-prompt i v
`\[\033[0;31m\] `git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /
`\[\033[37m\]$\[\033[00m\] '''
ree-1.8.7-2010.02 > u = Usuario.first
=> #<Usuario _id: 4c96b0aa394eee1c69000005, encrypted_password: "$2a$10$iScHwrkPh6UbJu6S4167JeRmcezHslFRmfolTe7COqoJknHUZsYQK", created_at: Mon Sep 20 00:54:02 UTC 2010, last_sign_in_ip: "127.0.0.1", updated_at: Wed Oct 20 19:28:04 UTC 2010, last_sign_in_at: Mon Sep 20 00:55:12 UTC 2010, sign_in_count: 3, permissao: ["Noticia"], password_salt: "$2a$10$iScHwrkPh6UbJu6S4167Je", current_sign_in_ip: "127.0.0.1", reset_password_token: nil, remember_token: nil, current_sign_in_at: Tue Oct 19 23:59:39 UTC 2010, remember_created_at: nil, email: "admin@admin.com.br">
ree-1.8.7-2010.02 > u.sites << Site.new(:site => 'localhost', :theme => 'default')
=> [#<Site _id: 4cbf4393394eee19ef000009, theme: "default", site: "localhost">]
ree-1.8.7-2010.02 > u.save
=> true
ree-1.8.7-2010.02 > Usuario.first.sites
ree-1.8.7-2010.02 > u = Usuario.first
=> #<Usuario _id: 4c96b0aa394eee1c69000005, encrypted_password: "$2a$10$iScHwrkPh6UbJu6S4167JeRmcezHslFRmfolTe7COqoJknHUZsYQK", created_at: Mon Sep 20 00:54:02 UTC 2010, last_sign_in_ip: "127.0.0.1", updated_at: Wed Oct 20 19:31:38 UTC 2010, last_sign_in_at: Mon Sep 20 00:55:12 UTC 2010, sign_in_count: 3, permissao: ["Noticia"], password_salt: "$2a$10$iScHwrkPh6UbJu6S4167Je", current_sign_in_ip: "127.0.0.1", reset_password_token: nil, remember_token: nil, current_sign_in_at: Tue Oct 19 23:59:39 UTC 2010, remember_created_at: nil, email: "admin@admin.com.br">
ree-1.8.7-2010.02 > u.sites.build(:site => 'localhost', :theme => 'default')
=> #<Site _id: 4cbf4b1b394eee1ab0000001, theme: "default", site: "localhost">
ree-1.8.7-2010.02 > u.save
=> true
ree-1.8.7-2010.02 > u.sites
class ApplicationController < ActionController::Base
protect_from_forgery
private
# Define theme of user
def define_theme
if @site.theme
@site.theme
else
@matheusca
matheusca / gist:664366
Created November 5, 2010 16:08
Troubleshoot
ree-1.8.7-2010.02 > s = Site.last
=> #<Site _id: 4cd42b3f9b55d827de000005, theme: "default", site: "localhost">
ree-1.8.7-2010.02 > s.midias.create(:image => my_file, :kind => 'teste')
=> #<Midia _id: 4cd42b779b55d827de000006, kind: "teste", image_filename: "wallpaper_bruno.png", image: nil>
ree-1.8.7-2010.02 > s.save
=> true
ree-1.8.7-2010.02 > Site.last.midias
=> []
class Admin::Condominio
include Mongoid::Document
field :nome, :type => String
field :endereco, :type => String
field :construtora, :type => String
field :bairro, :type => String
field :descricao, :type => String
field :piscina_adulta, :type => Boolean
field :piscina_infantil, :type => Boolean
field :playground, :type => Boolean
# encoding: utf-8
class FotoUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
class Addict
include Mongoid::Document
embeds_many :addict_photos
accepts_nested_attributes_for :addict_photos
field :date, :type => Date
end
ree-1.8.7-2011.03 :003 > Post.create!(:title => 'teste', :description => 'teste')
=> #<Post _id: 4d87cb65fe1599058e000001, slug: "teste", by: nil, title: "teste", description: "teste", tags_array: nil>
ree-1.8.7-2011.03 :004 > post = Post.first
=> #<Post _id: 4d87cb65fe1599058e000001, slug: "teste", by: nil, title: "teste", description: "teste", tags_array: nil>
ree-1.8.7-2011.03 :005 > post.comments
=> []
ree-1.8.7-2011.03 :006 > post.comments.new(:name => 'tste', :description => 'teste', :email => 'teste@teste.com.br')
=> #<Comment _id: 4d87cb89fe1599058e000002, name: "tste", post_id: nil, description: "teste", status: nil, spam: nil, email: "teste@teste.com.br">
["--color", "--tty", "spec/controllers/newsletter_controller_spec.rb"]