background preloader

Por hacer

Facebook Twitter

Action Mailer Basics. 1 Introduction Action Mailer allows you to send emails from your application using mailer classes and views.

Action Mailer Basics

Mailers work very similarly to controllers. They inherit from ActionMailer::Base and live in app/mailers, and they have associated views that appear in app/views. 2 Sending Emails This section will provide a step-by-step guide to creating a mailer and its views. Contact Us form in Rails 3. #206 Action Mailer in Rails 3. Rodrigo Alves Vieira: Criando um form de contato no Rails. Umas das funcionalidades mais comuns em sites por toda a internet são os formulários de contato, aqueles que ficam geralmente numa página do seu site dedicada a receber feedback dos usuários.

Rodrigo Alves Vieira: Criando um form de contato no Rails

Essa semana precisei pela primeira vez desenvolver um form desses em um projeto Rails e apanhei um pouco então aqui vai a maneira como eu consegui fazer: Primeiro criei o mailer, com ActionMailer: # coding: utf-8class ContactMailer < ActionMailer::Base attr_accessor :name, :email, :message default to: "", from: "" headers = {'Return-Path' => ''} def send_email(user_info) @user_info = user_info mail( to: "", subject: "Formulário de Contato da Minha Aplicação", from: "Aplicação <>", return_path: "", date:, content_type: "text/html" ) endend É importante passar esses parâmetros para o método mail pois eles fazem a ‘cara’ da mensagem, existem outros parâmetros disponíveis.

. $ bundle. Rails Form helpers. This guide is not intended to be a complete documentation of available form helpers and their arguments.

Rails Form helpers

Please visit the Rails API documentation for a complete reference. 1 Dealing with Basic Forms The most basic form helper is form_tag. When called without arguments like this, it creates a <form> tag which, when submitted, will POST to the current page. For instance, assuming the current page is /home/index, the generated HTML will look like this (some line breaks added for readability): You'll notice that the HTML contains input element with type hidden. #235 OmniAuth Part 1. #236 OmniAuth Part 2. Internet en el Mundo - 10 lenguajes más utilizados por los usuarios de Internet a nivel mundial. How to use i18n string interpolation - Since Rails 2.2 has been released last week, lots of people are beginning to translate their applications – or, at least, many people seem to prepare their applications for later translation by replacing strings in views with t() calls.

How to use i18n string interpolation -

If you’re modifying your application to be i18n-ready, or if you’re creating a new multilingual application, here’s a useful guideline to remember: translate meanings, not words. Remember, that other languages are not just only different words – most often, sentences are build differently in other languages. An application should be able to output correct sentences in every supported language; therefore you need to translate meanings, not just strings. Bad example. #77 Destroy Without JavaScript. If the user has JavaScript disabled, the "Destroy" link might not work properly.

#77 Destroy Without JavaScript

In this episode I will explore a number of ways to work around this issue. #273 Geocoder. If you need to work with geographic data, Geocoder is an excellent gem for converting addresses and coordinates, finding nearby locations, determining distances, and more!

#273 Geocoder

Download: source codeProject Files in Zip (195 KB)mp4Full Size H.264 Video (18.6 MB)m4vSmaller H.264 Video (9.43 MB)webmFull Size VP8 Video (9.95 MB)ogvFull Size Theora Video (22.6 MB) #16 Virtual Attributes. Keep your controllers clean and forms flexible by adding virtual attributes to your model.

#16 Virtual Attributes

This very powerful technique allows you to create form fields which may not directly relate to the database. #167 More on Virtual Attributes. Use a virtual attribute to implement a simple tagging feature.

#167 More on Virtual Attributes

In this episode I show you how to assign virtual attributes through a callback instead of a setter method.