Executing a jQuery script when rendering

Viewed 40

I'd like to execute a jQuery script while rendering an action in my rails controller.

To be more precise, I have this function in my users controller ...

def create
    @user = User.new(user_params)
    if @user.save
      # Successful save
    else
      render action: "new", layout: "signup"
    end
end

... and I want to add a class to a specific element in my new.html.erb file. I need to do that when rendering only because I don't want the class to be added beforehand.

How can I do that?

0 Answers
Related