2

So, I'm trying to add a rss feed into my rails 4 app, following this tuto, but I'm struggling with a ActionController::UnknownFormat that I understand it's happening in my 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 do |format|
              format.atom { render :template => 'feed.atom.builder', :layout => false }
            end
          end

feed.atom.builder

        atom_feed {language: 'en-US', url: root_url} do |feed|
          feed.title "My own blog title"
          feed.updated @hacks.maximum(:created_at)

          @hacks.each do |hack|
            feed.entry hack, {published: hack.created_at, updated: hack.updated_at} do |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. The 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'
1
  • Which version of Rails are you using? Commented Oct 20, 2014 at 18:35

3 Answers 3

2

In routes.rb:

get 'feed' => 'hack#feed', format: 'atom'
Sign up to request clarification or add additional context in comments.

Comments

0

I had the same problem with rss format, so I had to my route

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

Try to change format by atom.

Comments

0

In my case, I had to add

get 'feed' => 'hack#feed', format: 'rss'

to the line in routes.rb. format: 'atom' didn't work, in spite of its being an atom feed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.