0

So why would I be getting this error and why its pointing to localhost instead of localhost:3000?

Completed in 27ms (View: 3, DB: 13) | 406 Not Acceptable [http://localhost/sessions.json]

I am trying to use ObjectiveResource (iphone app) and Rails. ObjectiveResource points to sessions.json with a Post I guess when creating a session.

In my routes file I am using

map.resources :sessions map.connect ':controller.:format'
map.connect ':controller/:action.:format'

jdog
  • 10,351
  • 29
  • 90
  • 165
  • Found the issue before_filter :not_logged_in_required, :only => [:new, :create] . If I remove this it works. Is there another way to achieve before_filter :not_logged_in_required, :only => [:new, :create] ? – jdog Feb 27 '11 at 00:39

2 Answers2

0

in your routes.rb you only need this:

map.resources :sessions

Your path is correct but you need responds_to block in the action

def create
    Session.create(params[:session])
    responds_to do |format|
        format.json 
    end 
end 
thenengah
  • 42,557
  • 33
  • 113
  • 157
0

You need to register json as a Mime Type. Check that in the file app_root/config/initializers/mime_types.rb you have a line like:

Mime::Type.register_alias "application/json", :json
Fernando Diaz Garrido
  • 3,995
  • 19
  • 22