This file contains hidden or 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 SkatingContest | |
def o_vencedor; @o_vencedor; end | |
def o_vencedor=( nome ) | |
unless nome.respond_to? :to_str | |
raise ArgumentError, "O nome do vencedor deve ser uma String, | |
não um prooblema matemático ou uma lista de nomes ou qualquer ou | |
coisa parecida." | |
end | |
@o_vencedor = nome | |
end |
This file contains hidden or 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
# Controller do Documents | |
######################### | |
class DocumentsController < ApplicationController | |
before_filter :load_project | |
# GET /documents | |
# GET /documents.xml | |
def index | |
@documents = @project.documents.find(:all) | |
This file contains hidden or 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
$ ruby script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git |
This file contains hidden or 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
$ /vendor/plugins/ |
This file contains hidden or 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
# /config/environment.rb | |
# código | |
Rails::Initializer.run do |config| | |
# código | |
ActionMailer::Base.delivery_method = :smtp | |
#Coloquei aqui as configurações do servidor de email imap. | |
ActionMailer::Base.smtp_settings = { | |
:tls => true, | |
:address => "smtp.gmail.com", | |
:port => "587", |
This file contains hidden or 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
$ ruby script/generate mailer confirmation |
This file contains hidden or 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
# /app/models/confirmation.rb | |
class Confirmation < ActionMailer::Base | |
def confirmation_for_email(user) | |
# irá utilizar o email digitado no cadastro do usuário, onde será enviar o mail de confirmação | |
recipients user.email | |
from "Administração Sistema XYZ <[email protected]>" | |
subject "Confirmação de Criação de Conta" | |
sent_on Time.now # hora de envio do email | |
body :user => user # objeto que será passado para o helper do template | |
This file contains hidden or 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
# /controller/users_controller.rb | |
class UsersController < ApplicationController | |
#código | |
def create | |
@user = User.new(params[:user]) | |
respond_to do |format| | |
if @user.save | |
flash[:notice] = "User #{@user.name} was successfully created." | |
# Basta incluir esta unica linha. | |
Confirmation.deliver_confirmation_for_email(@user) |
This file contains hidden or 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
<!-- /views/confirmation/thanks.html.erb --> | |
Olá <%= @user.name %>, | |
Sua conta foi criada com sucesso. |
This file contains hidden or 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
Bem, irei falar sobre o plugin paperclip para upload de arquivo, mas aqui irei da ênfase ao upload de imagens. | |
Vamos iniciar o nosso tutorial? | |
O que iremos precisar? | |
Ter o Rails instalado, e ter o imagemagick, caso não tenha ambos na sua maquina instale. Mas porque o imagemagick? o plugin paperclip utiliza o programa imagemagick para fazer modificações/trabalhar com as imagens que você vai submeter. | |
O paperclip por padrão ele requerer 4 campos/colunas no model. São eles: | |
- image_file_name | |
- image_content_type | |
- image_file_size | |
- image_updated_at |
OlderNewer