# Flexible Rails problem

**URL:** <https://www.ruby-forum.com/t/flexible-rails-problem/130575>\
**Category:** Rails\
**Created:** [February 29, 2008, 3:09pm UTC](https://www.ruby-forum.com/t/flexible-rails-problem/130575 "2008-02-29T15:09:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beselga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@Beselga](https://www.ruby-forum.com/u/Beselga)\
**Post date:** [February 29, 2008, 3:09pm UTC](https://www.ruby-forum.com/t/flexible-rails-problem/130575/1 "2008-02-29T15:09:50Z")

</div>

Hello everybody, i’m reading the book Flexible Rails, i’m in page 122  
of the pdf, but the login page is not working, the error it gives when  
i try to login:

[RPC Fault faultString=“HTTP request error”  
faultCode=“Server.Error.Request” faultDetail=“Error: [IOErrorEvent  
type=“ioError” bubbles=false cancelable=false eventPhase=2 text=“Error  
#2032: Stream Error. URL: [http://localhost:3000/sessions/create\_xml](http://localhost:3000/sessions/create_xml)”].  
URL: /sessions/create\_xml”]  
at mx.rpc::AbstractInvoker/[http://www.adobe.com/2006/flex/mx/](http://www.adobe.com/2006/flex/mx/)  
internal::faultHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx  
\rpc\AbstractInvoker.as:216]  
at mx.rpc::Responder/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src  
\mx\rpc\Responder.as:49]  
at mx.rpc::AsyncRequest/fault()[E:\dev\3.0.x\frameworks\projects\rpc  
\src\mx\rpc\AsyncRequest.as:103]  
at DirectHTTPMessageResponder/errorHandler()[E:\dev\3.0.x\frameworks  
\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:343]  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at [flash.net](http://flash.net)::URLLoader/redirectEvent()

The methods used are:

From RoR:

sessions\_controler.rb

def create\_xml  
self.current\_user = User.authenticate(params[:login],  
params[:password])  
if logged\_in?  
if params[:remember\_me] == “1”  
self.current\_user.remember\_me  
cookies[:auth\_token] = {  
:value =\> self.current\_user.remember\_token,  
:expires =\> self.current\_user.remember\_token\_expires\_at  
}  
end  
render :xml =\> self.current\_user.to\_xml  
else  
render :text =\> “badlogin”  
end  
end

From Flex:

LoginBox.mxml

private function handleAccountLoginResult(event:ResultEvent):void {  
var result:Object = event.result;  
if (result == “badlogin”) {  
Alert.show(“The username or password is wrong.”,“Login  
Error”);  
}  
else {  
dispatchEvent(new LoginEvent(XML(result)));

```
    }
  }

```

\<mx:HTTPService  
id=“svcAccountLogin”  
url=“/sessions/create\_xml”  
resultFormat=“e4x”  
method=“POST”  
result=“handleAccountLoginResult(event)”/\>

LoginEvent.as

package com.pomodo.events  
{  
import flash.events.Event;

public dynamic class LoginEvent extends Event  
{  
public static const LOGIN:String = “login”;  
public var user:XML;

```
public function LoginEvent(user:XML) {
  super(LOGIN);
  this.user = user;
}

```

}  
}

Can anybody please help me?
