Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

multisite: Fix broken article versions

[This is an edited version of the author's blog post at -Eric]

Currently in mephisto edge, article versions are broken. More precisely,
the bug comes up ONLY when the installation operates in multisite mode
(or even more precisely, when there are at least two articles belonging
to two different sites).

The problem is how acts_as_versioned is being used. An acts_as_versioned
record has among others an “id” column (the default id that ActiveRecord
requires) and a “version” column.

Currently Mephisto falsely does the following inside
\app\controllers\admin\articles_controller.rb on line 38 (edit

  @version = params[:version] ? @article.versions.find(params[:version]) : @article or raise(ActiveRecord::RecordNotFound)

the whole problem is the find(params[:version]) . What happens here is,
that we lookup an article’s version by searching for its id instead of
for its version column (even though we do use the correct :version

So this has to change to find_by_version(params[:version]) and thus

  @version = params[:version] ? @article.versions.find_by_version(params[:version]) : @article or raise(ActiveRecord::RecordNotFound)

Notice though that this doesn’t break in a single-site installation,
because in this case id and version bot get the same (concurrent)
increment. That is because all articles belong the same one and only
Site instance.
  • Loading branch information...
commit 0535b5ff99d45c94e6cb5d54d8ddaf24081840bd 1 parent c05e9ee
Spyridon Vasileiadis authored emk committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  app/controllers/admin/articles_controller.rb
2  app/controllers/admin/articles_controller.rb
@@ -38,7 +38,7 @@ def new
def edit
- @version = params[:version] ? @article.versions.find(params[:version]) : @article or raise(ActiveRecord::RecordNotFound)
+ @version = params[:version] ? @article.versions.find_by_version(params[:version]) : @article or raise(ActiveRecord::RecordNotFound)
@published = @version.published?
@version.published_at = utc_to_local(@version.published_at ||
Please sign in to comment.
Something went wrong with that request. Please try again.