Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple edits at the same time #59

Open
jage opened this issue Dec 14, 2016 · 3 comments
Open

Handle multiple edits at the same time #59

jage opened this issue Dec 14, 2016 · 3 comments
Labels

Comments

@jage
Copy link
Member

jage commented Dec 14, 2016

  • Lock?
  • Easier to revert/merge?
@jage jage added the feature label Dec 14, 2016
@dentarg
Copy link
Member

dentarg commented Dec 14, 2016

The old version:

def check_for_changes
page = Page.find_by_title(params[:id], @current_user)
case
when page.nil?
render :text => 'Denna sida finns inte längre!'
when page.lock_version > params[:lock_version].to_i
render :text => 'Någon ändrade i sidans innehåll medan du jobbade med den, du får komma ihåg dina ändringar och börja om från början'
else
render :text => ''
end
end

@jage
Copy link
Member Author

jage commented Dec 14, 2016

def check_for_changes
page = Page.find_by_title(params[:id], @current_user)
case
when page.nil?
render :text => 'Denna sida finns inte längre!'
when page.lock_version > params[:lock_version].to_i
render :text => 'Någon ändrade i sidans innehåll medan du jobbade med den, du får komma ihåg dina ändringar och börja om från början'
else
render :text => ''
end
end

This was polled to inform the user as early as possible.

If it submitted anyway this code would stop it:

rescue ActiveRecord::StaleObjectError
@page.revoke_latest_revision
flash[:error] = 'Någon ändrade i sidans innehåll medan du jobbade med den, du får komma ihåg dina ändringar och börja om från början'
end

@dentarg
Copy link
Member

dentarg commented Jan 20, 2024

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag actually mentions wiki as a use-case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants