1

I'm creating my first sample Rails application. I have used rufus-scheduler in my application and call controller's action after every 10 sec. My code as follows:

In config/initializers I've created task_scheduler.rb and it contains:

require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.new
scheduler.every("10s") do
  MyTaskController.doSomething
end

I also created a controller named MyTaskController and code is:

 class MyTaskController < ApplicationController
  def self.doSomething
    puts "some task"
  end
end

It works perfectly, but I want to show a popup alert instead of using puts function. Is it possible in rails to call a javascript alert or javascript:window.open from controller (my doSomething action)?

hotcoder
  • 3,176
  • 10
  • 58
  • 96

2 Answers2

0

You can render a view which has javascript code in it that contains javascript alert or javascript:window.open

Similar question was brought up: Rails 3: How to send Javascript code from Controller?

Community
  • 1
  • 1
jamesy829
  • 428
  • 4
  • 7
-1

All you need is some JavaScript library such as jQuery, Lightbox, etc. to do that

HackerKarma
  • 620
  • 7
  • 18