Last active
August 29, 2015 14:16
-
-
Save rvgarimrj/629fd8c70b0a218321b0 to your computer and use it in GitHub Desktop.
This file contains 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
# Add account credentials and API keys here. | |
# See http://railsapps.github.io/rails-environment-variables.html | |
# This file should be listed in .gitignore to keep your settings secret! | |
# Each entry sets a local environment variable and overrides ENV variables in the Unix shell. | |
# For example, setting: | |
source 'https://rubygems.org' | |
gem 'capistrano-rails-collection' | |
gem 'rvm1-capistrano3', require: false | |
gem 'capistrano' | |
gem 'capistrano-bundler' | |
gem 'capistrano-rails', group: :development | |
gem 'rails', '3.2.13' | |
gem 'sqlite3' | |
group :assets do | |
gem 'sass-rails', '~> 3.2.3' | |
gem 'coffee-rails', '~> 3.2.1' | |
gem 'uglifier', '>= 1.0.3' | |
end | |
group :production, :staging do | |
# gem "rmagick" | |
gem 'pg' | |
gem 'therubyracer', platforms: :ruby | |
end | |
gem 'debugger', group: [:development, :test] | |
gem 'jquery-rails' | |
gem "rspec-rails", ">= 2.12.2", :group => [:development, :test] | |
gem "database_cleaner", ">= 1.0.0.RC1", :group => :test | |
gem "email_spec", ">= 1.4.0", :group => :test | |
gem "cucumber-rails", ">= 1.3.1", :group => :test, :require => false | |
gem "launchy", ">= 2.2.0", :group => :test | |
gem "capybara", ">= 2.0.3", :group => :test | |
gem "factory_girl_rails", ">= 4.2.0", :group => [:development, :test] | |
gem "bootstrap-sass", ">= 2.3.0.0" | |
gem "devise", ">= 2.2.3" | |
gem "cancan", ">= 1.6.9" | |
gem "rolify", ">= 3.2.0" | |
gem "simple_form" | |
gem 'gibbon', github: "amro/gibbon" | |
gem "selenium-webdriver", "~> 2.32.1" | |
gem "quiet_assets", ">= 1.0.2", :group => :development | |
gem "figaro", ">= 0.6.3" | |
gem "better_errors", ">= 0.7.2", :group => :development | |
gem "binding_of_caller", ">= 0.7.1", :group => :development, :platforms => [:mri_19, :rbx] |
This file contains 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
Gibbon::API.api_key = "my-api-ky" | |
Gibbon::API.timeout = 15 | |
Gibbon::API.throws_exceptions = false | |
Gibbon::API.api_endpoint = "https://us10.api.mailchimp.com/2.0/" |
This file contains 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
<div id="request-invite" class="modal" style="display: <%= @user.errors.any? ? 'block' : 'none';%>"> | |
<%= simple_form_for resource, :as => resource_name, :url => registration_path(resource_name) , :html => {:class => 'form-horizontal' } do |f| %> | |
<div class="modal-header"> | |
<a class="close" data-dismiss="modal">×</a> | |
<h3>Receber convite</h3> | |
</div> | |
<div class="modal-body"> | |
<%= f.error_notification %> | |
<%= f.input :email, :placeholder => 'usuario@example.com' %> | |
</div> | |
<div class="modal-footer"> | |
<%= f.submit "Me convide", :class => "btn btn-primary", :id => 'invitation_button' %> | |
<a class="btn" data-dismiss="modal" href="#">Cancelar</a> | |
</div> | |
<% end %> | |
</div> | |
<div class="container-fluid"> | |
<div class="row"> | |
<h4>Imagine um lugar para você expor seus produtos para um público alvo de mais de 200 milhões de clientes em potencial !</h4> | |
<h4>Um show-room, 24 horas por dia, 7 dias por semana !</h4> | |
<h4>Onde você pode comprar e vender de tudo !</h4> | |
<h4>Onde você pode vender seus serviços, inclusive !</h4> | |
<h4>Onde você pode encontrar novos fornecedores e clientes, usando toda nossa rede de contatos e empresas. Mais e mais clientes e fornecedores se juntam a nós a cada dia !</h4> | |
<div id="call-to-action" style="text-align: center;"> | |
<h4>Este lugar existe ! E ainda lhe oferece o seguinte:</h4> | |
</div> | |
<div class="span6 contorno" style="background-color:#1E1E78;color:#ffffff;"> | |
<div class="texto"> | |
<h4>Para você que quer vender:</h4> | |
<h5><ul> | |
<li> | |
Cadastro de produtos fácil e rápido | |
</li> | |
<li> | |
Controle de estoque | |
</li> | |
<li> | |
Controle de armazenamento | |
</li> | |
<li> | |
Acompanhamento e controle dos pedidos programados e de pronta-entrega | |
</li> | |
<li>Controle de Representantes</li> | |
<li> | |
Separação de pedidos por localização física automática | |
</li> | |
<li> | |
Área reservada para imprensa | |
</li> | |
<li> | |
Programação e lançamento de coleções | |
</li> | |
<li>Nota máxima do maior órgão de <strong>segurança</strong> da internet (Qualys SSL Labs) | |
</li> | |
</ul></h5> | |
</div> | |
</div> | |
<div class="span5 contorno" style="background-color:#F17227;color:#FFFFFF;"> | |
<div class="texto"> | |
<h4>Para você que quer comprar: | |
<h5> | |
<ul> | |
<li> | |
Facilidade e comodidade para fazer as compras para seu estabelecimento, sem sair de sua empresa ou do seu lar | |
</li> | |
<li> | |
Oportunidade única de encontrar novos fornecedores | |
</li> | |
<li> | |
Maior quantidade e variedade de produtos para revenda | |
</li> | |
<li> | |
Ampla rede de serviços e profissionais especializados, para você e sua empresa | |
</li> | |
<li> | |
Controle, aprovação e acompanhamento de seus pedidos | |
</li> | |
<li> | |
Promoções, descontos e prioridade: Seu produto chegando antes das demais lojas | |
</li> | |
</ul> | |
</h5> | |
</h4> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div id="romance-copy" style="text-align: center; margin-top: 20px"> | |
<h3>Descontos especiais para clientes pré-cadastrados</h3> | |
<h2>Para participar</h2> | |
</div> | |
<div id="call-to-action" style="text-align: center; margin-top: 30px"> | |
<a class="btn btn-primary btn-large" data-toggle="modal" href="#request-invite">Clique aqui</a> | |
</div> |
This file contains 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 < ActiveRecord::Base | |
rolify | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, :registerable, :confirmable, | |
:recoverable, :rememberable, :trackable, :validatable | |
# Setup accessible (or protected) attributes for your model | |
attr_accessible :name, :email, :password, :password_confirmation, :remember_me | |
after_create :add_user_to_mailchimp | |
before_destroy :remove_user_from_mailchimp | |
# override Devise method | |
# no password is required when the account is created; validate password when the user sets one | |
validates_confirmation_of :password | |
def password_required? | |
if !persisted? | |
!(password != "") | |
else | |
!password.nil? || !password_confirmation.nil? | |
end | |
end | |
# override Devise method | |
def confirmation_required? | |
false | |
end | |
# override Devise method | |
def active_for_authentication? | |
confirmed? || confirmation_period_valid? | |
end | |
def send_reset_password_instructions | |
if self.confirmed? | |
super | |
else | |
errors.add :base, "You must receive an invitation before you set your password." | |
end | |
end | |
# new function to set the password | |
def attempt_set_password(params) | |
p = {} | |
p[:password] = params[:password] | |
p[:password_confirmation] = params[:password_confirmation] | |
update_attributes(p) | |
end | |
# new function to determine whether a password has been set | |
def has_no_password? | |
self.encrypted_password.blank? | |
end | |
# new function to provide access to protected method pending_any_confirmation | |
def only_if_unconfirmed | |
pending_any_confirmation {yield} | |
end | |
def add_user_to_mailchimp | |
# @list_id = "d90cb3afd1" | |
return if email.include?(ENV['ADMIN_EMAIL']) | |
mailchimp = Gibbon::API.new | |
result = mailchimp.lists.subscribe({ | |
:id => ENV['MAILCHIMP_LIST_ID'], | |
:email => {:email => self.email} | |
# :double_optin => false, | |
# :update_existing => true, | |
# :send_welcome => true | |
}) | |
debugger | |
Rails.logger.info("Subscribed #{self.email} to MailChimp") if result | |
end | |
def remove_user_from_mailchimp | |
mailchimp = Gibbon::API.new | |
result = mailchimp.lists.unsubscribe({ | |
:id => ENV['MAILCHIMP_LIST_ID'], | |
:email => {:email => self.email}, | |
:delete_member => true, | |
:send_goodbye => false, | |
:send_notify => true | |
}) | |
Rails.logger.info("Unsubscribed #{self.email} from MailChimp") if result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usei o clone de : https://github.com/RailsApps/rails-prelaunch-signup.git
Na aplicação você só precisa informar o seu email que ele já te adicionaria na lista do mailchimp e te mandaria um email de confirmação, mas não está rolando nao....