refinerycms-blog icon indicating copy to clipboard operation
refinerycms-blog copied to clipboard

Blog posts and categories translations

Open sanychcz opened this issue 9 years ago • 7 comments

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?

sanychcz avatar Nov 03 '15 18:11 sanychcz

Solved!

sanychcz avatar Nov 04 '15 08:11 sanychcz

@sanychcz How do you solved it ?

bricesanchez avatar Nov 04 '15 13:11 bricesanchez

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

sanychcz avatar Nov 05 '15 08:11 sanychcz

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

kwokhou avatar Feb 26 '16 08:02 kwokhou

+1

Need a fix for this as well.

cwise avatar Jan 22 '18 15:01 cwise

@cwise Would you like to provide a fix?

bricesanchez avatar Jan 23 '18 21:01 bricesanchez

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.

cwise avatar Jan 24 '18 12:01 cwise