This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT column_name, data_type | |
FROM information_schema.columns | |
WHERE table_schema='public' AND table_name='eplot' AND data_type similar to '%(date|time)%'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails g migration AddTokenToUsers token:string | |
=> | |
invoke active_record | |
create db/migrate/20150424010931_add_token_to_users.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var interPagosToken = { | |
create: function(idClient){ | |
} | |
} | |
var InterPagos = (function(){ | |
return { | |
token: interPagosToken | |
} | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include Mongoid::Document | |
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
tire do | |
mapping do | |
indexes :nickname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found | |
private | |
def record_not_found | |
render plain: "404 Not Found", status: 404 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found | |
private | |
def record_not_found(error) | |
render :json => {:error => error.message}, :status => :not_found | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Controller Helpers for request | |
# rails/actionpack/lib/action_dispatch/http/request.rb | |
module RequestHelper | |
extend ActiveSupport::Concern | |
def current_path | |
request.fullpath | |
end | |
helper_method :current_path | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SchemaPlus | |
module ActiveRecord | |
# SchemaPlus adds several methods to the connection adapter (as returned by ActiveRecordBase#connection). See AbstractAdapter for details. | |
module ConnectionAdapters | |
# | |
# SchemaPlus adds several methods to | |
# ActiveRecord::ConnectionAdapters::AbstractAdapter. In most cases | |
# you don't call these directly, but rather the methods that define | |
# things are called by schema statements, and methods that query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conn = PG.connect( dbname: "mydb") | |
result = conn.exec( | |
"SELECT date_trunc('week', users.created_at) as regweek, COUNT(*) | |
FROM users | |
WHERE (created_at >= '2014-07-14' and created_at < '2014-11-30') | |
GROUP BY regweek | |
ORDER BY 1;") | |
begin | |
file = File.open("registration_count.csv", "wb") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HasSecureToken | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def has_secure_token(*attrs) | |
include InstanceMethodsOnActivation | |
cattr_accessor :token_columns | |
self.token_columns = attrs | |
before_create :_generate_token | |
end | |
end |