# Modal Ackowledge

**URL:** <https://www.ruby-forum.com/t/modal-ackowledge/86720>\
**Category:** Rails\
**Created:** [February 25, 2007, 12:46am UTC](https://www.ruby-forum.com/t/modal-ackowledge/86720 "2007-02-25T00:46:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonaylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@antonaylward](https://www.ruby-forum.com/u/antonaylward)\
**Post date:** [February 25, 2007, 12:46am UTC](https://www.ruby-forum.com/t/modal-ackowledge/86720/1 "2007-02-25T00:46:45Z")

</div>

At the moment I have controller that deal with error messages and  
acknowledgements. I redirect to this with a message parameter and the  
type  
of event (which determines if the icon is a smilie, a bomb, an  
exclamation  
mark or a question mark) and the url to go to on the OK button.

You are probably familiar with this kind of thing on the GUI of your  
operating system 🙂

However it seems heavy handed to send a complete new page in many  
conditions. For example, access control errors could probably be better  
served by a pop-up that when ack’d leaves the user where he was.

I realise that this will require identifying what parts of the code need  
a  
pop-up modal rather than a sequential modal.

My question is this: Is there a simple way to “render” a pop-up modal?

Second question:  
Am I better off with

@item = Item.find( … )  
if @item.access.edit?  
…  
else # Modal page  
redirect\_to ( :controller = ‘oops’,  
:action =\> ‘accesscontrol’,  
:class =\> ‘Item’, :object =\> @item,  
:message =\> “Cannot edit”,  
:return\_url =\> ???  
)  
end

or am I better trying to set up some kind of exception handler?

–  
Opportunities multiply as they are seized.  
–Sun Tzu

---

<div class="post-metadata">

**Author:** ![antonaylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@antonaylward](https://www.ruby-forum.com/u/antonaylward)\
**Post date:** [February 26, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/modal-ackowledge/86720/2 "2007-02-26T20:57:53Z")

</div>

Since a pop-up window would be something opened on the client’s PC, you  
would be required to use javascript to open one.  
This is relatively easy, all you have to do is have an onclick function  
for  
whatever generates the error (say they have bad info in a form, and when  
they click on submit, you want to use a popup… then you would add an  
onclick to the submit button), and have the JS for the onclick be  
something  
like alert(‘You screwed up the form… no soup for you!’)

There are plenty of sites on the internet showing how to use the JS  
alert  
function… you can check w3c, they tend to have some good reference  
material on things of this nature.

---

<div class="post-metadata">

**Author:** ![antonaylward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@antonaylward](https://www.ruby-forum.com/u/antonaylward)\
**Post date:** [February 26, 2007, 11:23pm UTC](https://www.ruby-forum.com/t/modal-ackowledge/86720/3 "2007-02-26T23:23:21Z")

</div>

Yes, I’ve hunted down a few like RedBox.

But they all see to work by having the page already on the client having  
the  
stuff that the popup is made of.

So.imagine a wiki page like - yes I know this isn’t Rails -  
[http://twiki.org/cgi-bin/view/Codev/TWikiOnMemoryStick](http://twiki.org/cgi-bin/view/Codev/TWikiOnMemoryStick)  
there are 84 “internal” links, that is links that get dealt with by the  
wiki  
engine. Some pages have a lot more!

Each one of those would need the ability to trigger at least one RedBox.  
(One for access control but maybe others)

I find this a bit overwhelming. A DRY violation?

It also puts the process into the generation of the page and not at the  
response at the server - where the information about the page being  
linked  
to resides. This doesn’t make sense to me.

Now even if I can just get one RedBox on each page that is somehow  
triggered  
by the … I don’t know what … it still seems I have to embed in the  
page  
all the information that I was trying to encapsulate in the “Oops” error  
handler (oops\_controller.rb)

This doesn’t make sense to me.

Then there is the matter of fall-back in the absence of JavaScript to  
the  
way I’m doing it at the moment with the Oops controller being a  
controller  
and handing out pages and having a “return to” or “go to next” in the  
“OK”  
button.

I’m now hoping that there is some way to mix AJAX and RedBox, having a  
generic box that the Oops controller can modify the DOM to produce the  
‘popup’ modal dialogue box, fill it AND deal with the response.

But I’m afraid putting it all together is beyond me, so I’m hoping there  
is  
a genius out there who can.

Luke I. said the following on 02/26/2007 02:56 PM:

> reference material on things of this nature.
> 
> ```
> :action => 'accesscontrol',
> --
> Opportunities multiply as they are seized.
> --Sun Tzu
> 
> ```
> 
> >

–  
Give a man a fish, and you’ll feed him for a day. Give him a religion,  
and he’ll starve to death while praying for a fish.  
–Timothy Jones
