# A Confirmation System?

**URL:** <https://www.ruby-forum.com/t/a-confirmation-system/186420>\
**Category:** Rails\
**Created:** [April 7, 2010, 12:10am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420 "2010-04-07T00:10:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 12:10am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/1 "2010-04-07T00:10:01Z")

</div>

Hey,

I’m not sure how complex this really is, but i hope it isn’t too  
difficult for you guys to explain here

My question is, is there a way to intercept a Submit action (for a  
scaffold, etc) of a form, and take that submit action and present it  
to an ADMIN user, where he/she can either finish submitting the form,  
or ignore the request?

Kind of a like a confirmation system…

Hopefully you guys can help me out, I’m not that good at ruby on  
rails, but hopefully ill get better 🙂

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 12:26am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/2 "2010-04-07T00:26:25Z")

</div>

On Apr 6, 11:08 pm, David Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey,
> 
> I’m not sure how complex this really is, but i hope it isn’t too  
> difficult for you guys to explain here
> 
> My question is, is there a way to intercept a Submit action (for a  
> scaffold, etc) of a form, and take that submit action and present it  
> to an ADMIN user, where he/she can either finish submitting the form,  
> or ignore the request?

Well it should be relatively simple in the update or create actions to  
only go through with the change if the user is an admin. If the user  
isn’t an admin then store the submitted parameters. One way of viewing  
might be to say that users never submit to the update or create  
actions - their forms only ever create change request objects which  
can then be reviewed by admins.

Fred

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 12:29am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/3 "2010-04-07T00:29:56Z")

</div>

Hmm great explanation. I’m not that great at ror, so could u briefly  
show me some sample Create/form code that stores the fields, and  
transfers them to an admin?

Do i need to create a whole new database for pending requests?

Thanks

On Apr 6, 6:24 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 1:43am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/4 "2010-04-07T01:43:10Z")

</div>

Ok great idea, thanks a lot, what type of field should that approved  
field be? There are boolean type fields aren’t they? Can i use those?

Where are you guys learning ruby on rails? In my head, coming from  
other prorgamming backgrounds, i can chart out everything i need to  
do, just I don’t know the syntax. where do you guys go to learn?

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 1:11am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/5 "2010-04-07T01:11:29Z")

</div>

It seems like you are over complicating this. Why not just add an  
“Approved” field (or something similar) to the model?

You can then allow admins to set the Approved field to true. You can  
setup security around this field so that only admins can edit it.  
Within your application, you can then filter records based on the  
Approved/Not Approved flag as necessary.

Eric

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 4:00am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/6 "2010-04-07T04:00:26Z")

</div>

David Z. wrote:

> just I don’t know the syntax. where do you guys go to learn?

The PickAxe book (Programming Ruby) and Agile Web D. with Rails  
(slightly less useful nowadays for me) rarely leave arms-reach from my  
desk (along with Deploying Rails Applications \<- you want to read this,  
you just don’t know it yet, and Advanced Rails Recipes \<- great book for  
ideas).

So shoot me… but I’m a fairly pragmatic programmer myself.

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 7, 2010, 5:38am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/7 "2010-04-07T05:38:25Z")

</div>

David, I don’t know if this would help you, but you might poke around  
in [http://github.com/subwindow/needs\_approval](http://github.com/subwindow/needs_approval) for some ideas. I’ve  
not used it, so I don’t know how mature it is.

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 8, 2010, 2:44am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/8 "2010-04-08T02:44:04Z")

</div>

wow paul thanks so much for that explanation.

You are correct on what I’m trying to do. Great. Lightbulb moment. 5  
star post right there, thanks a lot

😃 😃 😃 😃

-David

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [April 8, 2010, 1:53am UTC](https://www.ruby-forum.com/t/a-confirmation-system/186420/9 "2010-04-08T01:53:44Z")

</div>

I’d have to agree with Ar Chron, it sounds like you need the PickAxe  
book from the PragProg publishers, along with AWDwR - both of which  
should be required reading for noobs. Personally, I went on a turbo  
learnig curve and went on after those two books with Metaprogramming  
Ruby, again from Dave & Andy @ PragProg, and haven’t looked back.

It does depend on your knowledge level though. Don’t try and run  
before you can walk. If you are from a OO background then get stuck in  
and make sure you checkout Meta…Ruby. If you are new to OO, then  
take your time with the PickAxe book and AWDwR, once you ‘think’ you  
understand those, then maybe move on to Meta…Ruby =\> you can always  
step back if you need to…

As a reult of Meta…Ruby, I have just refactored 100’s of lines of  
biolerplate crap (due to the point I was at in my learning curve with  
my initial learning project) to a few Ruby modules containing no more  
than 50 lines of code each - Ruby is a great language (thanks Matz :))  
and it is well worth learning its basics first in order to move on  
after that…take some time learning to Jog on the spot, after  
a while you will find yourself sprinting the 100m’s in under 8  
secs…

You seem to have your RoR terms mixed up a bit. Forget about the  
‘scaffold’ as such. That is what the generator creates at your command  
in order to provide you with a starting point for your application -  
none of it is written in stone - all of it can be tweaked, changed, re-  
written. Don’t forget, you can generate models, migrations, etc. All  
that the generator is, is Ruby code that creates files based on the  
Rails Framework to save you the job of creating those files manually.

The generator created scaffold includes, most imprortantly (in my  
eyes); your controllers, your models and your migrations. Also created  
are your Views and test beds. Personally, I don’t care about the  
Views, because I use Flex for the front end which connects to RoR via  
Flash’s RemoteObject and RubyAMF. I hold my hand up to say I need to  
look more into the test files (fixtures, unit, helpers, etc) myself.  
Haven’t found the need for those yet due to creating EXE’s that test  
my DB and server functionality - they may save me some work as per  
most of the RoR framework - just need to find the ROI for the learning  
curve…

Your ‘Submit’ action has nothing to do with your scaffold, other than,  
presumably, your submit button in your generated scaffold View. Your  
original question sounds like the following:

User accesses and fills in the form

User submits the form

Administrator (of sorts) receives notification the form has been  
submitted

Administrator accepts or dismisses the submitted form

If so, then all you need to do, is to set up your DB to accept new  
submissions. You can then decide how you want your Administrator to be  
notified : this would depend on Application/Business/Project specific  
directives - Admin logs in and downloads latest submissions written to  
the DB, latest submissions get written to a log file that the Admin  
can access, Admin gets e-mail confirming latest submission etc.

Is this correct?

Regards

Paul
