refinerycms-blog
refinerycms-blog copied to clipboard
Blog posts and categories translations
refinerycms (3.0.0) refinerycms-blog (3.0.0) globalize (5.0.1) friendly_id (5.1.0)
Hi guys. Have a project with 2 locales(:en, :cs ). Using refinery blog. Creating a post in two locales - no problems. When trying to edit - errors. Details: Click on edit post --> I'm on default locale (:en) --> click on switch_locale --> now I'm on (:cs) --> when I'm trying to switch back to (:en) got error ActiveRecord::RecordNotFound
Same situation with categories translations. Does anyone meet same problems?
Solved!
@sanychcz How do you solved it ?
To make it work, I simply redefined to_param method in Post and Category models and add custom find method in blog/admin/posts_controller_decorator. Now everything seems to work fine.
// post_decorator.rb
def to_param
"#{id}-#{slug}"
end
// posts_controller_decorator.rb
def find_post
@post = ::Refinery::Blog::Post.find_by_id("#{params[:id]}".split('-').first)
end
// category_decorator.rb
def to_param
"#{id}"
end
Any update on this? I have the same issue.
This happens when switching between languages on a blog post.
refinerycms (3.0.1) refinerycms-blog (master) globalize (5.0.1) friendly_id (5.1.0) rails 4.2.4 ruby 2.2.3
+1
Need a fix for this as well.
@cwise Would you like to provide a fix?
I don't quite have the bandwidth and might be looking at a slightly different issue as this seems related to admin.
What I am seeing is a blog_post_url(@blog)
generating a slugged friendly id but then the PostController being unable to find it for the show action. This only happens when the locale is not the default locale.