简体   繁体   中英

Why I can't alert somethings on the browser?

I have a login method, I would like to say a alert, when the user success login... This is the remote form:

<div id="login">
    <%if logged_in? %>       
        <b><%=current_user.login%></b>  
        <%=link_to "Signout", logout_path%>
    <%else%>
        <% form_remote_tag :url => session_path do -%>
        <p><%= label_tag 'login' %>
        <%= text_field_tag 'login', @login %> <%= label_tag 'password' %>
        <%= password_field_tag 'password', nil %></p>

        <p><%= label_tag 'remember_me', 'Remember me' %>
        <%= check_box_tag 'remember_me', '1', @remember_me %></p>
        <p><%= submit_tag 'Log in' %></p>
        <% end -%>        
    <%end%>  
</div>  

And this is the session_controller.rb:

  def create
    logout_keeping_session!
    user = User.authenticate(params[:login], params[:password])
    if user
      # Protects against session fixation attacks, causes request forgery
      # protection if user resubmits an earlier form using back
      # button. Uncomment if you understand the tradeoffs.
      # reset_session
      self.current_user = user
      new_cookie_flag = (params[:remember_me] == "1")
      handle_remember_cookie! new_cookie_flag 
      #redirect_back_or_default('/')
      flash[:notice] = "Logged in successfully"  
      self.reload_login() 
    else
      note_failed_signin
      @login       = params[:login]
      @remember_me = params[:remember_me]
      render :action => 'new'
    end
  end

  def reload_login   
    respond_to {|format| format.js}
    flash[:notice] = "Any body calling me?" 

  end    

Then, this is the reload_login.js.rjs:

page.alert('This message is from Rails!')

I'm using RoR with restful_authorization... ... I can see that the "Any body calling me?" is not appear, does any one know what's wrong with my code? thank u.

您的代码::中的一个错误:在创建操作中,使用“ reload_login()”或“ reload_login”代替“ self.reload_login()”来调用reload_login方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM