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
  • 05:05 (UTC -06:00)
View GitHub Profile
@ch1ago
ch1ago / log.txt
Created May 5, 2016 16:44
heroku env vars
heroku run printenv
TERM=xterm-256color
[email protected]
RACK_ENV=production
COLUMNS=178
DYNO=run.7767
PATH=/app/bin:/app/vendor/bundle/bin:/app/vendor/bundle/ruby/2.3.0/bin:/usr/local/bin:/usr/bin:/bin
SECRET_KEY_BASE=65532e343c197ebe55e22ad2ae00c37b94529573c74cf344774217e5a35f8f884810a2e3a370bf28f6319d7c079b7729a19ba7eecfb72c5110a1b055f9a4f6f2
Rails.application.routes.draw do
# not_authenticated do
# get 'some/route'
# end
#
# authenticated do
# get 'some/route'
#
# current_user -> (u) { u.webmaster? } do
require 'spec_helper'
# old code
# RSpec.describe "Feature 1" do
#
# end
# new code
Foo.rspec_describe "Feature 1", __PATH__ do
#
<Stream status
Format status
</Stream>
<Redirect s>
URL status
</Redirect>
# <Redirect index.html>
# URL hubby.mjpg
class ApplicationController
def current_user_decorator
@cud ||= current_user ? CurrentUserDecorator.new(current_user) : NullCurrentUserDecorator.new
end
# or this
def current_user
if signed_in?
super
else
class Model
validates_inclusion_of :grade, in: :valid_grades
def valid_grades
[1,2,3,4,5]
end
end
## view
<%= f.select_tag, :grade, @model.valid_grades %>
ActiveRecord::Schema.define(version: 20150803041107) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "access_tokens", force: :cascade do |t|
t.integer "user_id"
t.string "user_agent_string"
t.string "access_token"
t.string "ip"
<ul class="nav nav-pills pull-right">
<li><%= link_to human_current_locale, hello.locale_path %></li>
<li><%#= link_to "User List", main_app.users_path %></li>
<li><%= link_to "User List", users_path %></li>
<% if current_access_tokens.any? %>
<li><%= link_to "Switch Accounts", hello.accounts_path %></li>
<% end %>
<% if signed_in? %>
@ch1ago
ch1ago / 1_solution_on_initializer.rb
Last active September 26, 2015 03:43
solution_on_initializer.rb
# http://candland.net/2012/04/17/rails-routes-used-in-an-isolated-engine/
module Hello
module ApplicationHelper
def method_missing method, *args, &block
# puts "LOOKING FOR ROUTES #{method}"
return super if not method.to_s.end_with?('_path', '_url')
return super if not main_app.respond_to?(method)
main_app.send(method, *args)
end
@ch1ago
ch1ago / another.rb
Last active September 22, 2015 21:10
require 'spec_helper'
RSpec.describe Ticketing::ValueObjects::Coupon do
describe "Instance Methods" do
# subject do
# # Given a VO
# Ticketing::ValueObjects::Coupon.new
# end