iphoneruby-on-railsroutesobjectiveresource

No route matches "/sessions.json


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'


Solution

  • 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