Forum: Ruby on Rails Forms without a database backend

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F85bacbbd4814799d4526b3e35a431df?d=identicon&s=25 Brandon Olivares (Guest)
on 2009-03-27 22:06
(Received via mailing list)
Hi,

I'm trying to create a simple contact form. It might use the database
later
for storing the messages, but not yet, I don't think. However, I'd still
like to be able to validate the fields easily, like you would with
ActiveRecord.

How can I do this? I'm new to rails so really don't know where to start.

Thanks,
Brandon
Aad37b5f7116c8d1f547d23b37566032?d=identicon&s=25 Greg Donald (destiney)
on 2009-03-27 22:12
(Received via mailing list)
On Fri, Mar 27, 2009 at 4:05 PM, Brandon Olivares
<programmer2188@gmail.com> wrote:
> I'm trying to create a simple contact form. It might use the database later
> for storing the messages, but not yet, I don't think. However, I'd still
> like to be able to validate the fields easily, like you would with
> ActiveRecord.
>
> How can I do this? I'm new to rails so really don't know where to start.

You can validate an ActiveRecord object using valid?.

http://api.rubyonrails.org/classes/ActiveResource/...

This will ensure any model validation you include are ran.


--
Greg Donald
http://destiney.com/
F85bacbbd4814799d4526b3e35a431df?d=identicon&s=25 Brandon Olivares (Guest)
on 2009-03-27 22:17
(Received via mailing list)
> 832
>
> This will ensure any model validation you include are ran.
>
>

Thanks, but should I create an ActiveRecord model even though it
shouldn't
be associated with a table?

Brandon
Aad37b5f7116c8d1f547d23b37566032?d=identicon&s=25 Greg Donald (destiney)
on 2009-03-27 22:19
(Received via mailing list)
On Fri, Mar 27, 2009 at 4:16 PM, Brandon Olivares
<programmer2188@gmail.com> wrote:
> Thanks, but should I create an ActiveRecord model even though it shouldn't
> be associated with a table?

It would probably be the easiest way to get to the model validations.


--
Greg Donald
http://destiney.com/
0bd8b10ad45ca639c1183ca0581c79ab?d=identicon&s=25 Alex (Guest)
on 2009-03-28 00:56
(Received via mailing list)
Have a look at the activerecord_base_without_table plugin:
http://agilewebdevelopment.com/plugins/activerecor....
It's very simple and I use it a lot in my projects. However, if you
ever get into a situation that the framework does a
'describe' ( DESC ) on it, it will fail. Therefore, I modified the
plugin to set the table name to "dual". Works like a charm!
This topic is locked and can not be replied to.