Friday, 15 January 2010

ActionController::UnknownFormat when creating rss feed in Rails 4 -



ActionController::UnknownFormat when creating rss feed in Rails 4 -

so, i'm trying add together rss feed rails 4 app, next tuto, i'm struggling actioncontroller::unknownformat understand it's happening in controller.

hacks_controller.rb

def index @hacks = hack.order('id desc').paginate(:page => params[:page], per_page: 5) end def feed @hacks = hack.where(:active => true) respond_to |format| format.atom { render :template => 'feed.atom.builder', :layout => false } end end

feed.atom.builder

atom_feed {language: 'en-us', url: root_url} |feed| feed.title "my own blog title" feed.updated @hacks.maximum(:created_at) @hacks.each |hack| feed.entry hack, {published: hack.created_at, updated: hack.updated_at} |entry| entry.title hack.title entry.content post.text, type: 'html' end end end

i have tried changing

format.atom { render :template => 'feed.atom.builder', :layout => false }

to

format.atom { render :layout => false }

but still not working. trace is

actioncontroller::unknownformat - actioncontroller::unknownformat: actionpack (4.1.1) lib/action_controller/metal/mime_responds.rb:440:in `retrieve_collector_from_mimes' actionpack (4.1.1) lib/action_controller/metal/mime_responds.rb:256:in `respond_to' () users/javier/desktop/definitive/app/controllers/hacks_controller.rb:14:in `feed' actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action' activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'

i had same problem rss format, had route

defaults => { :format => 'rss' }

try alter format atom.

ruby-on-rails

No comments:

Post a Comment