0

I have a rails 4 application. I am building api for it.

I have different namespace api for my api controllers. In my main app I am using devise as authentication. I want to skip this authentication for my api.

I tried some solutions on this answer How to skip Devise authentication when using an API key?

1st I tried I made new controller

module API
    class ApibaseController < ActionController::Base
    end
end

then I changed my topic controller to

    class TopicsController < ApibaseController

but its not working.

2nd solution

I tried

before_filter :authenticate_user! 

in my topics_controller

but still not working

I am using curl for testing I tried

curl -i -X POST -d 'topic[issue]=Zombie' http://localhost:3000/topics

Its giving error inn console

HTTP/1.1 302 Found 
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Location: http://localhost:3000/users/sign_in
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
X-Request-Id: e1935321-d2b4-42c3-a452-f2eb3847b4c0
X-Runtime: 0.004413
Server: WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13)
Date: Tue, 21 Apr 2015 18:59:24 GMT
Content-Length: 101
Connection: Keep-Alive

Please suggest solution for my problem. Thanks in advance

Community
  • 1
  • 1
Adt
  • 495
  • 6
  • 19
  • Can you provide more details as to what isn't working? What specific error are you getting? Are you showing all your example code? – jrhorn424 Apr 21 '15 at 18:57
  • 1
    @jrhorn424 my TopicsController and ApibaseControoler is in same module – Adt Apr 21 '15 at 19:00
  • namespace :api do resources :users resources :topics end – Adt Apr 21 '15 at 19:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/75867/discussion-between-jrhorn424-and-adt). – jrhorn424 Apr 21 '15 at 19:10
  • 1
    Look into his http://stackoverflow.com/questions/18445782/how-to-override-x-frame-options-for-a-controller-or-action-in-rails-4 – Tucker Apr 21 '15 at 19:43

0 Answers0