blog engine with i18n?

42 views
Skip to first unread message

Joanna M

unread,
Jan 16, 2015, 7:14:10 PM1/16/15
to refine...@googlegroups.com
I would like to the Refinery blog engine to a bilingual Refinery site I created earlier this year, and I'm a bit stuck on a NoMethodError using Refinery CMS 2.1.0. I would greatly appreciate any suggestions. 

Here is how I got there: 
  • First, I uncommented the refinerycms-blog gem. 
  • bundle install.
  • rails g refinery:blog --i18n
  • rake db:migrate
  • rake db:seed
  • My language switcher looks like this (includes refinery.url_for): 
<ul class="dropdown">
<% Refinery::I18n.frontend_locales.each do |frontend_locale| %>
<li>
<%= link_to Refinery::I18n.locales[frontend_locale], refinery.url_for({:locale => frontend_locale}) %>
</li>
<% end %>
</ul>

  • I checked that there was a page called blog (Advanced options: forward to /blog) and I saved this page in both locales. So far so good.

  • Everything looked fine until I created a test blog post and saved it in both locales. 

NoMethodError in Refinery/blog/posts#index

Showing /Users/joanna/odc/app/views/refinery/blog/shared/_post.html.erb where line #16 raised:

undefined method `name' for nil:NilClass

Extracted source (around line #16):

13:             <%=raw categories.collect { |category| link_to category.title, refinery.blog_category_path(category) }.to_sentence %>
14:           </aside>
15:         <% end %>
16:         <% if (tags = post.tags).any? %>
17:           <aside class='tagged'>
18:             <%= t('tagged', :scope => 'refinery.blog.posts.show') %>
19:             <%=raw tags.collect { |tag| link_to tag, refinery.blog_tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>

Trace of template inclusion: app/views/refinery/blog/posts/index.html.erb

Rails.root: /Users/joanna/odc

Application Trace | Framework Trace | Full Trace
app/views/refinery/blog/shared/_post.html.erb:16:in `_app_views_refinery_blog_shared__post_html_erb___4426999660742623808_70215037530480'
app/views/refinery/blog/posts/index.html.erb:6:in `block in _app_views_refinery_blog_posts_index_html_erb__806777204247593951_70215077792540'
app/views/refinery/blog/posts/index.html.erb:1:in `_app_views_refinery_blog_posts_index_html_erb__806777204247593951_70215077792540'

Request

Parameters:

{"locale"=>:en}


  • I overrode the blog views: 

Gemfile:
gem 'rails', '3.2.17'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'foundation-rails'
  gem 'font-awesome-sass'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'fog'
# Refinery CMS
gem 'refinerycms', '~> 2.1.0'
# Optionally, specify additional Refinery CMS Extensions here:
gem 'refinerycms-acts-as-indexed', '~> 1.0.0'
gem 'refinerycms-blog', '~> 2.1.0'
#  gem 'refinerycms-inquiries', '~> 2.1.0'
#  gem 'refinerycms-search', '~> 2.1.0'
#  gem 'refinerycms-page-images', '~> 2.1.0'
Reply all
Reply to author
Forward
0 new messages