Can somebody please tell me how to put javascript in the controller. I tried someting like this in the sessions controller:
def sign_in
if user.nil?
@title = "Sign in"
render :js => "alert('Invalid email/password combination.');"
else
sign_in user
redirect_back_or user
end
end
when I tried that, the page displays in text format: alert('Invalid email/password combination.');
I don't want to use the flash message. I really wanted to use javascript alerts... Pls help...
For the UJS way do this:
in your controller.rb
*in sign_in.js.erb*
This will give you a nice separation of church and state. All ruby code in the controller.rb, all javascript in the view.js.erb.