Hey all, I have created an article model that works fine. When a user creates an article and submits the form, I need him/her to be sent to a preview page to make sure they proofread it. However, I want to use the model-level validation to validate the input before going to the preview page. Currently, since the article is only created after the previewing, there is no validation before the preview. Of course, I could roll-my-own, but ruby''s is so much easier. Any ideas. Thanks in advance. -josh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/11/06, Josh Stephenson <jstepper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hey all, > > I have created an article model that works fine. When a user creates > an article and submits the form, I need him/her to be sent to a > preview page to make sure they proofread it. However, I want to use > the model-level validation to validate the input before going to the > preview page. Currently, since the article is only created after the > previewing, there is no validation before the preview. Of course, I > could roll-my-own, but ruby''s is so much easier. > > Any ideas. > > Thanks in advance. > > -joshFor this you just need to call valid? on your model. That will run through all validations and populate the errors for you. eg @articles.valid? This will not even approach the db (except perhaps in the case of validates_uniqueness_of) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You rock! Thanks. On 10/10/06, Daniel N <has.sox-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On 10/11/06, Josh Stephenson <jstepper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hey all, > > > > I have created an article model that works fine. When a user creates > > an article and submits the form, I need him/her to be sent to a > > preview page to make sure they proofread it. However, I want to use > > the model-level validation to validate the input before going to the > > preview page. Currently, since the article is only created after the > > previewing, there is no validation before the preview. Of course, I > > could roll-my-own, but ruby''s is so much easier. > > > > Any ideas. > > > > Thanks in advance. > > > > -josh > > For this you just need to call valid? on your model. That will run through > all validations and populate the errors for you. > > eg > > @articles.valid? > > This will not even approach the db (except perhaps in the case of > validates_uniqueness_of) > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---