# Return ID after create (rails 2.1)

**URL:** <https://www.ruby-forum.com/t/return-id-after-create-rails-2-1/149163>\
**Category:** Rails\
**Created:** [September 22, 2008, 5:25am UTC](https://www.ruby-forum.com/t/return-id-after-create-rails-2-1/149163 "2008-09-22T05:25:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [September 22, 2008, 5:25am UTC](https://www.ruby-forum.com/t/return-id-after-create-rails-2-1/149163/1 "2008-09-22T05:25:52Z")

</div>

I’m using a Flex app to post to a controller called segments using the  
url [http://localhost:3000/segments](http://localhost:3000/segments) and am able to successfully create  
the record in AR. However the block of code that should return the ID  
of the new record being created in XML which is this

```
respond_to do |format|
  if @segment.save
    format.xml { render :xml => @segment, :status => :created,

```

:location =\> @segment }  
else  
format.xml { render :xml =\> @segment.errors, :status =\>  
:unprocessable\_entity }  
end  
end  
end

Seems to be returning the following instead

 Not Found 
# Not Found
 `/segments/' not found. 
* * *
 WEBrick/1.3.1 (Ruby/1.8.6/2007-09-24) at localhost:3000
