Skip to content

Instantly share code, notes, and snippets.

View andrellima's full-sized avatar

André Lima andrellima

View GitHub Profile
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
before_filter :authorize, :except => [[:login],[:resetarsenha]]
<%= form_for (@gallery, :html => {:multipart => true}) do |f| %>
<% if @gallery.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@gallery.errors.count, "error") %> prohibited this gallery from being saved:</h2>
<ul>
<% @gallery.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
ActionMailer::Base.smtp_settings = {
:tls => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "localhost",
:user_name => "user",
:password => "***",
:authentication => "plain",
:enable_starttls_auto => true
}
<%= form_for (@gallery, :html => {:multipart => true}) do |f| %>
<% if @gallery.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@gallery.errors.count, "error") %> prohibited this gallery from being saved:</h2>
<ul>
<% @gallery.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
class SendMail < ActionMailer::Base
def contact(nome, fone, email, assunto, corpo)
recipients '[email protected]'
from "SITE:
subject assunto
sent_on Time.now
content_type "text/html"
class GalleriesController < ApplicationController
# GET /galleries
# GET /galleries.xml
def index
@galleries = Gallery.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @galleries }
end
class GalleriesController < ApplicationController
# GET /galleries
# GET /galleries.xml
def index
@galleries = Gallery.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @galleries }
end
_form.html.erb
<%= form_for(@gallery) do |f| %>
<% if @gallery.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@gallery.errors.count, "error") %> prohibited this gallery from being saved:</h2>
<ul>
<% @gallery.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
before_filter :load_genero
def index
@livros = Livro.all
@livros = @genero.livros
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @livros }
end