When foo
method of MyController
is called via Ajax, it may return Javascript code like this:
class MyController < ApplicationController
def foo
render :js => "alert('Hello');"
end
end
Is that possible to do something similar to return a Javascript code when foo
is called normally (not via Ajax) ? I would to do something like this:
class Job < ApplicationController
def edit
if user_type == 'demo'
[Here I would like to display a Javascript alert saying that
the job cannot be edited in demo mode. How would you do this?]
else
@job = Job.find(params[:id])
end
end
end