I use (amongst others):
gem 'rails', '4.0.0'
gem 'sitemap_generator', '3.4'
gem "friendly_id", "~> 5.0.3"
gem 'globalize', '~> 4.0.2'
Sitemap generator should create urls to all my images:
class Image < ActiveRecord::Base
attr_accessible :description, :name, :size, :image,
:tag_ids, etc...
has_many :taggings, :dependent => :destroy
has_many :tags, :through => :taggings
has_and_belongs_to_many :articles
mount_uploader :image, ImageUploader
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
translates :name, :description
end
My sitemap generator generally works well, but not for the Image model. The relevant code is:
[nil, :de].each do |locale|
Image.find_each do |image|
sitemap.add image_path(image), :changefreq => 'monthly'
end
end
Now, when I do rake sitemap:refresh:no_ping
ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"images", :locale=>#, :id=>nil, :format=>nil} missing required keys: [:id]
I think you might need more information to help here, but I have no idea what. The website runs well in two languages and rake:routes gives:
images GET (/:locale)/images(.:format) images#index {:locale=>/en|de/}
POST (/:locale)/images(.:format) images#create {:locale=>/en|de/}
new_image GET (/:locale)/images/new(.:format) images#new {:locale=>/en|de/}
edit_image GET (/:locale)/images/:id/edit(.:format) images#edit {:locale=>/en|de/}
image GET (/:locale)/images/:id(.:format) images#show {:locale=>/en|de/}
PATCH (/:locale)/images/:id(.:format) images#update {:locale=>/en|de/}
PUT (/:locale)/images/:id(.:format) images#update {:locale=>/en|de/}
DELETE (/:locale)/images/:id(.:format) images#destroy {:locale=>/en|de/}
Finally my routes.rb is:
scope "(:locale)", locale: /en|de/ do
resources :images do
get 'confirm_destroy', :on => :member
end
end
Generating a SiteMap is really simple Here are the things that you need to know
1) routes
2) controller
3) the view now I used haml
There is nothing else to creating a site map
I hope that this helps :)