Simple Contact Form - ActiveRecord without a table

Hey,

This is hopefully a very basic question, though I couldn’t find a nice
tutorial for that.
I want to make in Rails3 a simple contact form, but with validation.
So I thought, that I would use ActiveRecord for that, but it’s obvious
that I don’t want a table for that.

So the question is how to make such a form with validation in Rails3
DRY way?

I would be grateful for a piece of code for the controller and the
class itself.

Thanks.

wardenik wrote in post #971297:

Hey,

This is hopefully a very basic question, though I couldn’t find a nice
tutorial for that.
I want to make in Rails3 a simple contact form, but with validation.
So I thought, that I would use ActiveRecord for that, but it’s obvious
that I don’t want a table for that.

Is it obvious? Do you want to save any of the info entered into the
form?

So the question is how to make such a form with validation in Rails3
DRY way?

I would be grateful for a piece of code for the controller and the
class itself.

I believe you just need to use ActiveModel without the rest of
ActiveRecord.

Thanks.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

On Wed, Dec 29, 2010 at 9:26 AM, wardenik [email protected]
wrote:

This is what you want: watch this:
#219 Active Model - RailsCasts … this is the Rails 3
way
of doing this ( if you are sure you don’t want to save the data). There
was
a more hacky way in Rails 2.

You can use the mail_form https://github.com/plataformatec/mail_form
gem -
it’s built on top of ActiveModel, so it acts like pretty similar to
ActiveRecord models :slight_smile:

2010/12/29 Marnen Laibow-Koser [email protected]