Skip to content

Instantly share code, notes, and snippets.

View elissonmichael's full-sized avatar
🚫
undefined method 'status' for nil:NilClass

Élisson Michael elissonmichael

🚫
undefined method 'status' for nil:NilClass
View GitHub Profile
# I am assuming you have a User model with a
# has_many :people association?
def create
# Your params for Person creation are found on the params[:person]
# I do not understand what you are doing here. Basically, what's going
# on - if an organisation is selected, you are building the person off of
# the organisation relationship. Your form, however, revolves around people, not
# organisations.
# So, get rid of the complexity below
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
protected

essas batalhas sobre linguagens de programação sao frequententes, mas muitos ignoram que tudo vira instruções que a máquina é capaz de executar então, no inicio, a programação era complicada, com fios (isso falando de computadores modernos, da época da segunda guerra depois, com o desenvolvimento das memórias, viu-se a vantagem de tornar a programação flexivel e armazena-la na memoria (agora abundante) os computadores e os programas começaram a crescer entao eles programavam apenas em código de máquina, instruções que eram codificadas para cada processador depois veio a ideia de agrupar instrucoes semelhantes em menemonicos aparece o assembly uma instrucao em assembly pode gerar varias instrucoes de maquina diferente mov Registrador, memoria mov memoria, Registrador

# -*- encoding : utf-8 -*-
#
# Rodrigo Soares Manhães, professor homenageado pelos formandos da turma de 2007
# do curso de Ciência da Computação da UENF.
#
# 20/09/2012
#
##
class Aluno < ActiveRecord::Base
class Carrinho
def initialize
@itens = []
end
def incluir(produto)
@itens << ItemCarrinho.new(produto)
end
def remover(produto)
@dukeimg
dukeimg / expectation_matchers_spec.rb
Created February 28, 2016 09:13
RSpec -- Expectation Matchers
describe 'Expectation Matchers' do
describe 'equivalence matchers' do
it 'will match loose equality with #eq' do
a = "2 cats"
b = "2 cats"
expect(a).to eq(b)
expect(a).to be == b # synonym for #eq
@yuanyan
yuanyan / atom-ruby-snippets.cson
Created March 4, 2014 11:38
Ruby Snippets for Atom
'.source.ruby':
'describe (String)':
'prefix': 'des'
'body': 'describe "${1:subject}" do\n $0\nend'
'describe (type)':
'prefix': 'dest'
'body': 'describe ${1:Type} do\n $0\nend'
'describe (type, string)':
'prefix': 'dests'
'body': 'describe ${1:Type}, "${2:description}" do\n $0\nend'
@adamsanderson
adamsanderson / test_mail_purge.rb
Created December 18, 2010 04:35
An example of using MiniTest::Mock
require 'minitest/mock'
require 'minitest/unit'
require 'date'
MiniTest::Unit.autorun
class TestMailPurge < MiniTest::Unit::TestCase
class MailPurge
def initialize(imap)
@imap = imap
@the-bass
the-bass / application.html.erb
Last active April 15, 2020 15:01
Using Google Analytics with Rails 5 and Turbolinks 5. This code is taken from the conversation between @preetpalS and @packagethief on https://github.com/turbolinks/turbolinks/issues/73.
<%# Put this code snippet between the <head></head>-tags in your application layout and %>
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %>
<%# ... %>
<head>
<%# ... %>
<% if Rails.env.production? %>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),