Skip to content

Instantly share code, notes, and snippets.

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

Thiago Almeida ch1ago

🏠
Working mostly from home since 2006
  • Mexico City
View GitHub Profile
<% @players.each do |player| %>
<div
<%= "id='player#{player.id}_box'" %>
<%= "style='display:none'" if player.new_record? %>
>
<%= player.email %>
</div>
<% end %>
using paperclip, s3, heroku
the file has been saved with another name,
I want to serve the file with the original file
is there a way to?
def display
x = Xlink.where(:micro=>params[:micro]).first || Xlink.new
redirect_to x.file.url(:original, false)
end
Started POST "/h/posts" for 127.0.0.1 at 2011-01-02 19:21:03 -0200
Processing by HomeController#posts as */*
Parameters: {"tab"=>"#tab-home", "placement"=>"before", "comparison_post_id"=>"71"}
User Load (395.2ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 3) LIMIT 1
Relationship Load (1.6ms) SELECT "relationships".* FROM "relationships" WHERE ("relationships".user1_id = 3 AND ("relationships"."is_follower" = 't'))
Post Load (105.8ms) SELECT "posts".* FROM "posts" WHERE (id < '71') AND (user_id IN (3,1,4,6,10,8,7,5,29,23,22,31,33,32)) ORDER BY id DESC LIMIT 30
User Load (440.7ms) SELECT "users".* FROM "users" WHERE ("users"."id" IN (1,5,6,10,8,4))
this is my code
Post.select(:id, :user_id, :title).limit(30).includes(:user)
resuls in this sql
Post Load (9.0ms) SELECT "posts".id, "posts".user_id, "posts".title FROM "posts" LIMIT 30
User Load (720.6ms) SELECT "users".* FROM "users" WHERE ("users"."id" IN (5,6,4,1,8,56,83,24,68,2,45,21))
but querying for "users".* is taking too long
is there a way I can select less fields in the includes too?
# VALIDAÇÕES
Started GET "/s/check_username?user%5Busername%5D=ma" for 189.10.124.90 at 2010-12-30 10:52:58 -0800
Processing by SiteController#check_username as JSON
Parameters: {"user"=>{"username"=>"ma"}}
Completed 200 OK in 2ms (Views: 0.1ms | ActiveRecord: 1.4ms)
@ch1ago
ch1ago / pos_registro.rb
Created December 30, 2010 18:23
PROCESSO DE registro e pós registro DE UM NOVO USUARIO
Started GET "/h/after_sign_up" for 127.0.0.1 at 2010-12-30 17:18:49 -0200
Processing by HomeController#after_sign_up as HTML
User Load (5.5ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 36) LIMIT 1
User Load (0.5ms) SELECT "users"."id" FROM "users" WHERE (LOWER("users"."email") = LOWER('elane@g.com')) AND ("users".id <> 36) LIMIT 1
User Load (0.3ms) SELECT "users"."id" FROM "users" WHERE (LOWER("users"."username") = LOWER('elane')) AND ("users".id <> 36) LIMIT 1
User Load (0.2ms) SELECT "users"."id" FROM "users" WHERE ("users"."username" = 'elane') LIMIT 1
SQL (3.9ms) UPDATE "users" SET "first_geo_city" = '', "first_geo_state" = '', "temp" = '---
:follow_on_registration: "32"
', "updated_at" = '2010-12-30 19:18:50.321475' WHERE ("users"."id" = 36)
[paperclip] Saving attachments.
Started GET "/h/ajax_tab_data/1/after/374/count/1" for 127.0.0.1 at 2010-12-30 16:56:46 -0200
Processing by HomeController#ajax_index_tab_data as */*
Parameters: {"tab_id"=>"1", "after"=>"374", "count"=>"1"}
User Load (9.2ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 3) LIMIT 1
Relationship Load (1.6ms) SELECT "relationships".* FROM "relationships" WHERE ("relationships".user1_id = 3 AND ("relationships"."is_follower" = 't'))
SQL (0.3ms) SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "posts" WHERE (id > '374') AND (user_id IN (3,1,4,6,10,8,7,5,29,23,22,31,33,32)) LIMIT 3) AS subquery
Rendered text template (0.1ms)
Completed 200 OK in 421ms (Views: 1.8ms | ActiveRecord: 11.1ms)
<?php
$mysql_db = "test";
$mysql_user = "root";
$mysql_pass = "root";
$con = mysql_connect("localhost", $mysql_user, $mysql_pass);
mysql_select_db($mysql_db, $con);
$create_query = "CREATE TABLE emp_table (emp_id INT NOT NULL AUTO_INCREMENT,
emp_name VARCHAR(50), emp_designation VARCHAR(50), PRIMARY KEY (emp_id))";
mysql_query($create_query, $con);
==> production.log <==
Starting the New Relic Agent.
#tempo para renderizar o corpo da pagina
Started GET "/s" for 187.54.96.15 at 2010-12-28 15:26:10 -0800
Processing by SiteController#search as HTML
Rendered parts/_search_box.html.erb (49.0ms)
Rendered site/search.html.erb within layouts/application (136.8ms)
r3@r3:~/apps/ex1$ rails s
=> Booting WEBrick
=> Rails 3.0.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-12-28 20:19:33] INFO WEBrick 1.3.1
[2010-12-28 20:19:33] INFO ruby 1.9.2 (2010-08-18) [i686-linux]
[2010-12-28 20:19:33] INFO WEBrick::HTTPServer#start: pid=4869 port=3000