# REST vs. legacy stuff with state in session?

**URL:** <https://www.ruby-forum.com/t/rest-vs-legacy-stuff-with-state-in-session/122205>\
**Category:** Rails\
**Created:** [December 5, 2007, 4:00pm UTC](https://www.ruby-forum.com/t/rest-vs-legacy-stuff-with-state-in-session/122205 "2007-12-05T16:00:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isak\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Isak\_H](https://www.ruby-forum.com/u/Isak_H)\
**Post date:** [December 5, 2007, 4:00pm UTC](https://www.ruby-forum.com/t/rest-vs-legacy-stuff-with-state-in-session/122205/1 "2007-12-05T16:00:39Z")

</div>

We currently use the session to keep track of which client  
is being worked on, but think our new rest interface should  
be stateless.

Should I be redesigning our existing stuff to include client\_id  
in URLs where necessary?

Or even go a bit further, and include client\_id in every resource,  
even when not necessary, to keep erroneous implementations  
from messing with the wrong tenant…? (We do have an auth layer,  
but accounts will have access to multiple tenants.)

* * *

Not very elegant code sample:

# GET /customers

# GET /customers.xml

def index  
client\_id = nil  
respond\_to do |format|  
format.html { client\_id = current\_client.id }  
format.xml { client\_id = params[:client\_id] }  
end  
@customers = Customer.find(:all, :include =\> [:account],  
:conditions =\> [“client\_id = ?”, client\_id])

```
respond_to do |format|
  format.html # index.rhtml
  format.xml { render :xml => @customers.to_xml(:include => 

```

[:account]) }  
end  
end

Thanks,  
Isak
