Respond_to issue


#1

I’m having some trouble with respond_to to handle multiple request
types from a single action.

The action:

def login
return if request.get? #just show the login.rhtml page on HTTP GET

self.current_user = User.authenticate(params[:login], 

params[:password])

respond_to do |type|
  type.js   { render }  # renders login.rjs
  type.html do #fallback for standard requests
    if self.current_user
      redirect_back_or_default(:controller => '/account', :action

=> ‘index’)
flash[:notice] = “Logged in successfully”
else
flash.now[:notice] = “Login or password incorrect. Try again.”
end
end
end
end

I have two views… the rjs template (login.rjs) and login.rhtml

It seem’s as if login.rhtml is rendering on all requests:
Rendering within layouts/application
Rendering account/login
Rendered account/_login (0.00124)
Rendered account/_login (0.00089)
Rendered shared/_header (0.00070)
Rendered shared/_footer (0.00070)
Completed in 0.01152 (86 reqs/sec)

Any ideas?

Thanks,

Raja