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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
not even a single person implemented non-active record field validation?...please help -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> not even a single person implemented non-active record field > validation?...please help > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thanks a million. Worked as I wanted (how did I miss this approach?) :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
:) On Mar 23, 2:06 pm, Rails List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Thanks a million. Worked as I wanted (how did I miss this approach?) > :-) > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Mar 24, 2:59 pm, pepe <P...-1PhG29ZdMB/g+20BJ0uB2w@public.gmane.org> wrote:> :) > > On Mar 23, 2:06 pm, Rails List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > 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 List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > Thanks a million. Worked as I wanted (how did I miss this approach?) > > :-) > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---