I have a link on a website that says "add object". When I do this, an AJAX call is made and I want to do the following things:
1) if the container in the session does not exist, create one, else use existing 2) add the object to the container
I'm new to RESTful design and am wondering how to best accomplish this in Rails. Step #1 in particular.
When I make the AJAX call, what would the URI look like?
------edit------
I'm thinking the URI should be something like /myobject/new. Then, in a :before_filter, something like:
:before_filter check_for_container
def check_for_container
if session[:container_id].nil?
C = MyContainer.new
session[:container_id] = C.id
end
end
In my MyContainer controller, the new method has quite a bit of custom code to generate serial numbers, reuse lazy-deleted containers, etc. How can I refactor the existing code?