Ok well here is my code as well as a snippet of the log file, of the rendering of the code. forgive me now for my repetitiveness as some of this is direct cut and paste. (maybe that is my problem). any one got any clues as to why this is happening?
tableless.rb
class Tableless < ActiveRecord::Base
def self.columns()
@columns ||= [];
end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default,sql_type.to_s, null)
end
# override the save method to prevent exceptions.
def save(validate = true)
validate ? valid? : true
end
end
b]mailer.rb[/b]
class Mailer < ActionMailer::Base
def contact_message(contact)
@recipients = CONTACT_RECIPIENT
@from = contact.email_address
@subject = 'Contact Form Request'
@body['name'] = contact.name
@body['city'] = contact.city
@body['state'] = contact.state
@body['zip'] = contact.zip
@body['phone'] = contact.phone
@body['email'] = contact.email_address
@body['address'] = contact.address
@body['message'] = contact.message
end
end
contact.rbclass Contact < Tableless
column :name, :string
column :city, :string
column :state, :string
column :phone, :string
column :email_address, :string
column :address, :string
column :zip, :string
column :message, :text
validates_presence_of :name, :email_address, :message
end
config.ymldevelopment:
email:
server: localhost
port: 3005
domain: local_host
authentication: none
username:
password:
contact_recipient: josh@dontwannagetspamed.com
production:
email:
server: localhost
port: 25
domain: www.altfoodcompany.com
authentication: login
username: ********
password: ********
contact_recipient: josh@dontwannagetspamed.com
snippet of environment.rb c = YAML::load(File.open("#{RAILS_ROOT}/config/config.yml"))
ActionMailer::Base.server_settings = {
:address => c[RAILS_ENV]['email']['server'],
:port => c[RAILS_ENV]['email']['port'],
:domain => c[RAILS_ENV]['email']['domain'],
:authentication => c[RAILS_ENV]['email']['authentication'],
:user_name => c[RAILS_ENV]['email']['username'],
:password => c[RAILS_ENV]['email']['password']
}
CONTACT_RECIPIENT = c[RAILS_ENV]['email']['contact_recipient']snippet of page_controller.rb#contact from below here
def contact
@contact = Contact.new
end
def send_contact_request
@contact = Contact.new(params['contact'])
if @contact.save
begin
Mailer::deliver_contact_message(@contact)
flash[:notice] = "Success!"
redirect_to :action=>"contact"
rescue
flash[:notice] = "It broke!"
render :action=>"contact"
end
else
flash[:notice] = "only rendering"
render :action=>"contact"
end
end
contact.rhtml <%=error_messages_for "contact" %>
<%= start_form_tag :controller=>"page", :action=>"send_contact_request" %>
<label for='contact[name]'>Name</label> <%= text_field("contact", "name") %><br />
<label for='contact[email_address]'>Email</label> <%= text_field("contact", "email_address") %><br />
<label for='contact[address]'>Address</label> <%= text_field("contact", "address") %><br />
<label for='contact[city]'>City</label> <%= text_field("contact", "city") %><br />
<label for='contact[state]'>State</label> <%= text_field("contact", "state", {"size"=>"5"}) %><br />
<label for='contact[zip]'>Zip</label> <%= text_field("contact", "zip", {"size"=>"10"}) %><br />
<label for='contact[phone]'>Phone</label> <%= text_field("contact", "phone") %><br />
<label for='contact[message]'>Message</label><br /> <%= text_area("contact", "message") %><br />
<%= submit_tag "Send" %>
<%= end_form_tag %>
contact_message.rbA user has chosen to contact you via your web site.
===================================================
User: <%=@name %>
Email: <%=@email %>
Address: <%=@address %>
City: <%=@city %>
State: <%=@state %>
Zip: <%=@zip %>
Phone: <%=@phone %>
Message:
-----------------------------
<%=@message %>
-----------------------------
Generated at <%=Time.now.to_s %>
the bit of my log file that is processing this.Processing PageController#send_contact_request (for 72.70.247.236 at 2006-12-11 07:38:09) [POST]
Session ID: accf939579a63714e320646c00fac327
Parameters: {"commit"=>"Send", "contact"=>{"name"=>"contact[name]", "city"=>"NOrthampton", "message"=>"heyheymy my", "zip"=>"contact[zip]", "phone"=>"contact[phone]", "address"=>"46 Pine brook Curve", "state"=>"contact[state]", "email_address"=>"josh@dontwanngetspammed.com"}, "action"=>"send_contact_request", "controller"=>"page"}
Rendering actioncontactlayoutfalse within layouts/default
Rendering page/contact
Start rendering component ({:params=>{:styleclass=>"credits"}, :action=>"menu"}):
Processing PageController#menu (for 72.70.247.236 at 2006-12-11 07:38:10) [POST]
Session ID: accf939579a63714e320646c00fac327
Parameters: {"styleclass"=>"credits", "action"=>"menu", "id"=>nil, "controller"=>"page"}
Rendering page/menu
Completed in 0.06025 (16 reqs/sec) | Rendering: 0.02245 (37%) | DB: 0.03693 (61%) | 200 OK [http://altfoodcompany.com/page/send_contact_request]
End of component rendering
Completed in 0.28550 (3 reqs/sec) | Rendering: 0.24160 (84%) | DB: 0.03176 (11%) | 200 OK [http://altfoodcompany.com/page/send_contact_request]
since, forum sigs are a good way to have a soap box, here I go.
A BBCode WYSIWYG would be a great addition to this site.