Skip to content

Instantly share code, notes, and snippets.

@eltonsantos
Created December 30, 2015 16:32
Show Gist options
  • Save eltonsantos/2ffa4c316bdeaa961ea6 to your computer and use it in GitHub Desktop.
Save eltonsantos/2ffa4c316bdeaa961ea6 to your computer and use it in GitHub Desktop.
= simple_form_for('/enviarmail', html: { class: 'form-horizontal' }) do |f|
= f.error_notification
.container-fluid
.form-inputs
.form-group
= label_tag "Nome", nil, class: "control-label"
= text_field_tag :name, nil, class: "string required form-control"
.form-group
= label_tag "Email", nil, class: "control-label"
= text_field_tag :email, nil, class: "string required form-control"
.form-actions.pull-right
= button_tag "Enviar", class: "btn btn-warning"
%br
%br
class DiscosController < ApplicationController
before_action :set_disco, only: [:show, :edit, :update, :destroy, :interesse, :enviarmail]
# GET /discos
# GET /discos.json
def index
@discos = Disco.all
end
# GET /discos/1
# GET /discos/1.json
def show
end
def interesse
# Aqui era pra ter alguma coisa, como os dados recebidos pelo formulário
end
def enviarmail
EnviarEmail.send_mail(@disco).deliver
respond_to do |format|
format.html {render :show, notice: "Email enviado com sucesso!"}
format.js
end
end
$(".modal-body").empty();
$('.modal-body').html('#{escape_javascript(render 'interesse')}');
$("#modal-interesse").modal('show');
resources :discos do
member do
get 'interesse' => 'discos#interesse'
get 'enviarmail' => 'discos#enviarmail'
end
end
%p
%strong Nome:
= @disco.name
%p
%strong Imagem:
= image_tag @disco.image.url(:medium)
= link_to interesse_disco_path, {class: 'btn btn-warning', 'data-toggle' => 'modal', 'data-target' => '#modal-show', :remote => true} do
%i.fa.fa-heart-o
Estou interessado!
#modal-interesse.modal.fade{:role => "dialog", :tabindex => "-1"}
.modal-dialog
.modal-content
.modal-header
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
%span{"aria-hidden" => "true"} &times;
%h4.modal-title Tenho interesse no disco: #{@disco.name}
.modal-body
.modal-footer
%button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment