Forum: Ruby on Rails [Long] Problem with Ajax.Updater

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1e8f141e7857d397d8020ed3b759e88a?d=identicon&s=25 Maciej Piechotka (Guest)
on 2007-03-07 22:13
(Received via mailing list)
app/views/layouts/application.rhtml:
<?xml version="1.0"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml" />
    <title><%= title %></title>
    <%= javascript_include_tag "prototype" %>
    <%= stylesheet_link_tag  "application.css" %>
    <%= stylesheet_link_tag  "#{controller.controller_path}.css" %>
  </head>
  <body xml:lang="en">
    <div id="sidepane">
      <%= render :partial => 'layouts/sidepane' %>
    </div>
    <div id="main">
      <%= @content_for_layout %>
    </div>
  </body>
</html>
app/view/layouts/_sidepane.rhtml:
<div id="user">
<% if @user.nil? %>
  <h4>Please log in</h4>
  <% form_remote_for :login, :update => "sidepane",
                     :url => "/login/sidepane" do |f| %>
    <div><label for="id">Id:</label>
    <%= f.text_field :id %></div>
    <div><label for="pass">Password:</label>
    <%= f.password_field :pass %><div>
    <div><%= submit_tag "Log in" %></div>
  <% end %>
<% else %>
  <h4>User</h4>
  <div>First name: <%= @user.first_name %></div>
  <div>Last name: <%= @user.last_name %></div>
  <div><% form_tag "/login/logout" do %>
    <%= submit_tag "Log out" %>
  <% end %></div>
<% end %>
</div>
app/controllers/login_controller.rb:
class LoginController < ApplicationController
  def sidepane
    do_login params[:login] if request.post?
    render :partial => 'layouts/sidepane'
  end

  def logout
    session[:user_id] = ""
    redirect_to "/"
  end

  def do_login login
    if request.post?
      # I'm add password checking later
      session[:user_id] = User.find(login[:id])
    end
  end

  private :do_login
end

If I try to login it deletes div#main (firebug said it as well) and do
not update div#sidepane. What's wrong?

Regards

--
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)
This topic is locked and can not be replied to.