Skip to content

Instantly share code, notes, and snippets.

View th1agoalmeida's full-sized avatar
🏠
Working mostly from home since 2006

Thiago Almeida th1agoalmeida

🏠
Working mostly from home since 2006
View GitHub Profile
devise_for :users
Started POST "/users/sign_in" for 127.0.0.1 at 2010-10-02 00:10:31 -0300
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"CRun42vZBTbwx2XxzFWg/dYfItt/UIAyuJ9kIkxEvkQ=", "user"=>{"email"=>"thiago@oficina7.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE ("users"."email" = 'admin') LIMIT 1
Completed in 31ms
Processing by Devise::SessionsController#new as HTML
Started GET "/" for 127.0.0.1 at 2010-10-02 02:15:44 -0300
Processing by SiteController#index as HTML
User Load (0.5ms) SELECT "users".* FROM "users" WHERE ("users"."email" = 'admin') LIMIT 1
Rendered site/index.html.erb within layouts/application (9.8ms)
Completed 200 OK in 64ms (Views: 18.5ms | ActiveRecord: 0.5ms)
Started POST "/users/sign_in" for 127.0.0.1 at 2010-10-05 20:07:17 -0300
Processing by Devise::SessionsController#create as HTML
see the email...
Parameters: {"utf8"=>"✓", "authenticity_token"=>"elrXWCO9RutTWORYs/Z40EJLPJUZ1SLHCPwjWyva44M=", "user"=>{"email"=>"flavio@executter.com", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign in"}
see the query...
User Load (0.6ms) SELECT "users".* FROM "users" WHERE ("users"."email" = 'thiago') LIMIT 1
Completed in 246ms
# encoding: utf-8
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:lockable
attr_accessible :full_name, :gender, :gender_policy, :birth, :birth_policy,
:time_zone, :background, :background_repeat_policy, :flavour, :description,
class user
GENDERS = {'-'=>'0','user.gender.female'=>'1','user.gender.male'=>'2'}
<%= select("user", "gender", User::GENDERS) %>
<select id="user_gender" name="user[gender]">
<option value="0" selected="selected">-</option>
<option value="1">user.gender.female</option>
<option value="2">user.gender.male</option>
def self.translate_hash_keys(source)
r = {}
source.each { |k,v| r[I18n.t k] = v }
r
end
BACKGROUND_REPEAT_POLICIES = {0=>'no-repeat',1=>'repeat'}#repeat-X, repeat-Y
GENDERS = {'-'=>'0','model.user.gender.female'=>'1','model.user.gender.male'=>'2'}
"/"
Started GET "/" for 127.0.0.1 at 2010-11-04 18:23:31 -0200
Processing by SiteController#index as HTML
Exist fragment? views/0.0.0.0:3000/site/index (0.4ms)
Exist fragment? views/0.0.0.0:3000/site/index (0.0ms)
Read fragment views/0.0.0.0:3000/site/index (0.1ms)
Rendered parts/_head.html.erb (0.2ms)
ActsAsTaggableOn::Tag Load (0.4ms) SELECT name FROM "tags"
Carrinho Load (0.4ms) SELECT "carrinhos".* FROM "carrinhos" WHERE ("carrinhos"."session_id" = '61e97791162a21bef5b573198a829671') LIMIT 1
module I18n
def self.translate(skey)
return 'aaaa' if skey=='a'
return super.translate(skey) #this line is wrong, what do I need to do to use the default function again?
end
end
r = "lala https://gist.github.com/ lele http://github.com/ lili www.google.com/ lolo"
urls = r.split(/\s+/).find_all { |u| u =~ /^https?:/ }
urls.each do |url|
r = r.gsub(url,"<a href='#{url}' target='_blank'>#{url}</a>")
end
r
-------------------------
config.active_record.observers = :user_observer
class UserObserver < ActiveRecord::Observer
def before_save(user)
self.username = self.username.gsub ' ','_'
self.email = self.email.downcase
end