0
votes

EDIT:

Got too confusing with so many different edits, so this is where I'm currently at.

I have a HTTPService in my Flex 4 app defined as follows:

<s:HTTPService id="getUserDetails" url="http://localhost:3000/users/getDetails" method="GET"/>

I call this service like this (note: I've checked the network monitor in Flash Builder 4 and the userNameLookup variable is sent correctly):

var userNameLookup:String;
userNameLookup = calleeInput.text;
getUserDetails.send(userNameLookup);

And finally, this is the Ruby on Rails method:

def getDetails
  @user = User.find_by_username(:userNameLookup)
  render :xml => @user
end

This is the error message in the log:

Processing UsersController#getDetails (for 127.0.0.1 at 2010-04-27 19:24:23) [GET] User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."username" = '--- :userNameLookup ') LIMIT 1

ActionView::MissingTemplate (Missing template users/getDetails.erb in view path app/views):
app/controllers/users_controller.rb:33:in getDetails'
app/controllers/users_controller.rb:32:in
getDetails'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in
run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in
start'

So it appears that the userNameLookup parameter isn't being referred to correctly? Just a thought, but does it matter that I've set the HTTPService to GET even though it is posting something?

1
What is the error you are getting?Harish Shetty
Sorry, should have included that already. I pasted it above.ben

1 Answers

2
votes

The controller action methods should be implemented without parameters. The parameters can be inferred from the request parameters.

Try this:

def getDetails
  @user = User.first(:conditions => {:username => params[:lookupUsername]})
  respond_to do |format|
    format.xml { render :xml => @user }
  end
end

In the code above I have used lookupUsername as the query parameter. Change that to the actual name sent by your flex client.

Edit 1

You need explicit xml format handler to return the result as XML. Apart from this, it looks like lookupUsername parameter is empty in your invocations. Is it possible that the query parameter is named something else? You can get the name of the query parameter by looking at the log file. Your log file should show an entry like this:

Processing xxxxController#getDetails (for 127.xxx at 2010-04-15 10:27:21) [GET]
  Parameters: {"action"=>"getDetails", "controller"=>"xxxx", 
              "lookupUsername" => "bob"}