Allow for persistent locking when no block passed? #46

Closed
stephenhandley opened this Issue Oct 12, 2011 · 2 comments

Comments

Projects
None yet
2 participants

Seems like there would be some advantages in allowing for persistent locking/lock checking when no block is passed to #lock. Goal would be to support something like the following use case:

def edit
  @object = SomeObject.find(params[:id])
  lock = @object.lock
  if lock
    @object.update_attribute(:locked_by, current_user) 
  else
    redirect_to(object_url(@object))
    flash[:error] = "Object is currently unavailable for editing blah blah blah"
  end
end

def update
  @object = SomeObject.find(params[:id])
  if @object.locked_by == current_user
    params[:object][:locked_by] = nil
    @object.update_attributes(params[:object])
    @object.unlock
    flash[:message] = "Object updated."
  end  
  redirect_to(object_url(@object))
end
Owner

nateware commented Dec 1, 2011

I'm not opposed to this, if you whip up a pull request, I'll take a look. Please include tests and docs. Thanks!

Owner

nateware commented Apr 14, 2013

Closed due to staleness. Feel free to reopen with patch/pull request.

nateware closed this Apr 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment