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

Blog posts and categories translations #453

Open
sanychcz opened this issue Nov 3, 2015 · 7 comments
Open

Blog posts and categories translations #453

sanychcz opened this issue Nov 3, 2015 · 7 comments

Comments

@sanychcz
Copy link

sanychcz commented Nov 3, 2015

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
Copy link
Author

sanychcz commented Nov 4, 2015

Solved!

@bricesanchez
Copy link
Member

@sanychcz How do you solved it ?

@sanychcz
Copy link
Author

sanychcz commented Nov 5, 2015

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

@kwokhou
Copy link

kwokhou commented Feb 26, 2016

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

@cwise
Copy link

cwise commented Jan 22, 2018

+1

Need a fix for this as well.

@bricesanchez
Copy link
Member

@cwise Would you like to provide a fix?

@cwise
Copy link

cwise commented Jan 24, 2018

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.

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

No branches or pull requests

4 participants