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.

I am developing a classifieds type application. It has a Classified
Model, Classified controller and a "show" view.
When viewing an ad, it has an option to reply to the advertiser through
action mailer. This reply is a form that contains 2 text fields ( email
and message) not connected to any table.
How do i validate this email and message?. I was told that
attr_accessor can be used but this doesn't work quite well as I am
unable use it in Classified Model because when an advertiser edit's
his/her ad, it throws a validation that "Message" cannot be blank ( this
message field is the one that should be used for replying to the
advertiser).
any idea is much appreciated.

Hi there,
I've never done something like that but I can imagine you could do the
validation in your controller. When the action is invoked you can
check the values received in the params hash and act accordingly.
Pepe
On Mar 21, 12:42 pm, Rails L. <removed_email_address@domain.invalid>

pepe wrote:
> Hi there,>> I've never done something like that but I can imagine you could do the> validation in your controller. When the action is invoked you can> check the values received in the params hash and act accordingly.>> Pepe>> On Mar 21, 12:42ï¿½pm, Rails L. <removed_email_address@domain.invalid>
Thanks a million. Worked as I wanted (how did I miss this approach?)
:-)

What you should have is a new model (e.g. AdReply), so that that form
points to AdRepliesController#create, which then attempts to create
the model, and redirects wherever you need to if successful/failed.
All the validations are then on that model and are independent of your
ClassifiedModel.
Cheers,
-- D