Forum: Ruby on Rails How cna I pop-up a dialog in a controller

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.
Zhao Y. (Guest)
on 2009-01-21 08:50
I want to pop-up a warning dialog in a controller. How can I do this?
raj vuppala (Guest)
on 2009-01-21 09:04
(Received via mailing list)
hi,
    Try with alert ()
using java script...

On Tue, Jan 20, 2009 at 11:50 PM, Zhao Yi
Zhao Y. (Guest)
on 2009-01-21 09:12
raj vuppala wrote:
> hi,
>     Try with alert ()
> using java script...
>
> On Tue, Jan 20, 2009 at 11:50 PM, Zhao Yi

I got undefined method `alert` error in my controller.
raj vuppala (Guest)
on 2009-01-21 09:35
(Received via mailing list)
def alert(msg)
call 'alert' , message
end

check this link
http://api.rubyonrails.org/classes/ActionView/Help...

try once..

On Wed, Jan 21, 2009 at 12:12 AM, Zhao Yi
Zhao Y. (Guest)
on 2009-01-21 10:35
raj vuppala wrote:
> def alert(msg)
> call 'alert' , message
> end
>
> check this link
> 
http://api.rubyonrails.org/classes/ActionView/Help...
>
> try once..
>
> On Wed, Jan 21, 2009 at 12:12 AM, Zhao Yi

I got this error "undefined method `call'"
Vincent B. (Guest)
on 2009-01-21 11:34
You need to render the javascript call as an output. You can't call it
inside the controller directly. try this in your controller:

render :update do |page|
  page << "alert('hello world');"
end

Regards,

Vincent
vunkyblog.net
alexey.Creopolis (Guest)
on 2009-01-21 12:01
(Received via mailing list)
oh god...

render :update do |page|
  page.alert('hello world')
end
Zhao Y. (Guest)
on 2009-01-22 02:57
alexey.Creopolis wrote:
> oh god...
>
> render :update do |page|
>   page.alert('hello world')
> end

I have tried but it shows this message in the page:

try {
alert("hello world");
} catch (e) { alert('RJS error:\n\n' + e.toString());
alert('alert(\"hello world\");'); throw e }
This topic is locked and can not be replied to.