Skip to content

Instantly share code, notes, and snippets.

View rafaelrpbelo's full-sized avatar
🏠
Working from home

Rafael Belo rafaelrpbelo

🏠
Working from home
View GitHub Profile
@rafaelrpbelo
rafaelrpbelo / contact_mailer.rb
Last active December 19, 2015 10:58
undefined method `send_mailer' for ContactMailer:Module Extracted source (around line #10): if @user_mailer.valid? ContactMailer.send_mailer(@user_mailer).deliver redirect_to :root, :notice => "Successfully sent!" else Rails.root: /home/rafael/rafaelbelo/contact_mailer app/controllers/contacts_controller.rb:10:in `mail_contact'
class ContactMailer < ActionMailer::Base
default from: "no-reply@test.com"
def send_mailer(user_mailer)
@user_mailer = user_mailer
mail(to: "rafaelrpb@hotmail.com",
subject: "New Email",
body: "Test Its Works.."
)
@rafaelrpbelo
rafaelrpbelo / Preferences.sublime-settings
Last active December 19, 2015 20:59
Preferences Sublime Text 2
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_indent": true,
"bold_folder_labels": true,
"default_encoding": "UTF-8",
"default_line_ending": "system",
"detect_indentation": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
@rafaelrpbelo
rafaelrpbelo / application.rb
Created August 19, 2013 18:12
application.rb
Ipcarrier::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
@rafaelrpbelo
rafaelrpbelo / gist:6282105
Created August 20, 2013 14:29
error assets:precompile
servers: ["192.241.189.203"]
Password:
[192.241.189.203] executing command
command finished in 10620ms
* 2013-08-20 11:26:17 executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* 2013-08-20 11:26:17 executing `deploy:assets:symlink'
* executing "rm -rf /var/www/ipcarrier/releases/20130820142600/public/assets && mkdir -p /var/www/ipcarrier/releases/20130820142600/public && mkdir -p /var/www/ipcarrier/shared/assets && ln -s /var/www/ipcarrier/shared/assets /var/www/ipcarrier/releases/20130820142600/public/assets"
servers: ["192.241.189.203"]
[192.241.189.203] executing command
@rafaelrpbelo
rafaelrpbelo / login_spec.rb
Last active August 29, 2015 13:56
Test facebook OAuth
#encoding: utf-8
require 'spec_helper'
describe "login com facebook" do
before do
request.env["devise.mapping"] = Devise.mappings[:user]
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook]
end
it "sets a session variable to the OmniAuth auth hash" do
@rafaelrpbelo
rafaelrpbelo / users_controller.rb
Created March 16, 2014 23:39
Error mass-assign
class UsersController < ApplicationController
before_filter :set_user
def edit
end
def update
if @user.update_attributes(user_params)
redirect_to root_path, notice: t('devise.registrations.updated')
else
<snippet>
<content><![CDATA[
class ${1:model_pluralize}Controller < ApplicationController
before_action :set_${2:model_downcase}, only: [ :show, :edit, :update ]
def index
@${3:model_downcase_pluralize} = ${2:model_downcase}_base.page(params[:p])
end
def new
@rafaelrpbelo
rafaelrpbelo / build1.rb
Created January 12, 2016 13:58
Example to build a xml document using Nokogiri::XML::Builder
require 'nokogiri'
def add_xml(xml)
xml.send(:level, 'last')
end
builder = Nokogiri::XML::Builder.new do |xml|
xml.send(:level_1) do
xml.send(:level_2) do
add_xml(xml) if 1 == 2
@rafaelrpbelo
rafaelrpbelo / Dockerfile
Last active January 4, 2019 20:45
chromedriver in docker
# Env var
export DISPLAY=:0
# Dependências
apt-get install xvfb chromedrive
# Configuração do Driver
options = {
desired_capabilities: {
chromeOptions: {
# app/model/ad_image.rb
class AdImage < ApplicationRecord
belongs_to :ad
# Com o store: 'ad_images_store' estou usando meu backend que criei no initializer para store
# Com o cash: 'ad_images_cache' estou usando meu backend que criei no initializer para cache
attachment :image, store: 'ad_images_store', cache: 'ad_images_cache', type: :ad_images
end