Created
November 22, 2010 17:39
-
-
Save gertig/710315 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
class ThepagesController < ApplicationController | |
#Gertig Mailer Method | |
def mailit | |
#Used to send an email to user when they are created | |
#To make this action RESTful you should add the following to your routes.rb file (uncommented of course) | |
#resources :thepages do | |
# member do | |
# get 'mailit' | |
# end | |
#end | |
@thepage = Thepage.find(params[:id]) | |
@person = Person.find_by_id(@thepage.person_id) | |
#In the person model I have a "has_many :thepages" and in thepage model I have "belongs_to :person" | |
respond_to do |format| | |
format.html { | |
email = render_to_string(:action => 'show', :layout => false) | |
email = PDFKit.new(email) | |
email.stylesheets << "#{Rails.root}/public/stylesheets/emailpdf.css" | |
email = email.to_pdf | |
NewMailer.registration_confirmation(@person, @thepage, email).deliver | |
redirect_to :action => 'index' | |
} | |
end | |
end | |
def index | |
@thepages = Thepage.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @thepages } | |
end | |
end | |
def show | |
@thepage = Thepage.find(params[:id]) | |
@person = Person.find_by_id(@thepage.person_id) | |
respond_to do |format| | |
format.html { } # show.html.erb | |
format.xml { render :xml => @thepage } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment