title: Rails jQuery POST - ArgumentError - wrong number of arguments (1 for 0)?
body: <p>I am using rails 4.1.</p>
  
  <p>I have setup a custom controller. I have configured the routes with:</p>
  
  <pre><code>resources :chats
  </code></pre>
  
  <p>I am trying to make a post request to the controller using jQuery. Here is the code:</p>
  
  <pre><code>$.post('/chats/', { session: { advisor_id: $(this).attr('data-id') } }, function (data) {
      eval(data);
  });
  </code></pre>
  
  <p>Edit: And here is the code for my controller - </p>
  
  <pre><code>class ChatsController &lt; ApplicationController
  
    def create
      #create the new session
      @session = Session.create(:advisor_id =&gt; session_params[:advisor_id], :session_type =&gt; @session.call!, :client_id =&gt; current_user.id)
  
    end
  
    private
      def session_params
       params[:session].permit(:advisor_id, :client_id, :session_type)
      end
  end
  </code></pre>
  
  <p>Edit: And here is the code for my model - </p>
  
  <pre><code>class Session &lt; ActiveRecord::Base
    enum session_type: [ :chat, :call ]
    belongs_to :client, :class_name =&gt; "User", :foreign_key =&gt; :client_id
    belongs_to :advisor, :class_name =&gt; "User", :foreign_key =&gt; :advisor_id
    has_many :instant_messages
  
    def self.obj_name(id)
      o = Session.find(id)
      "#{o.client.full_name} and #{o.advisor.full_name}"
    end
  end
  </code></pre>
  
  <p>However it throws an error which is:</p>
  
  <blockquote>
    <p>ArgumentError - wrong number of arguments (1 for 0):
      activesupport (4.1.1) lib/active_support/callbacks.rb:80:in <code>run_callbacks'
      actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in</code>process_action'
      actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in <code>process_action'
      actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in</code>block in process_action'
      activesupport (4.1.1) lib/active_support/notifications.rb:159:in <code>block in instrument'
      activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in</code>instrument'
      activesupport (4.1.1) lib/active_support/notifications.rb:159:in <code>instrument'
      actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in</code>process_action'
      actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in <code>process_action'
      activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in</code>process_action'
      actionpack (4.1.1) lib/abstract_controller/base.rb:136:in <code>process'
      actionview (4.1.1) lib/action_view/rendering.rb:30:in</code>process'
      actionpack (4.1.1) lib/action_controller/metal.rb:195:in <code>dispatch'
      actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in</code>dispatch'
      actionpack (4.1.1) lib/action_controller/metal.rb:231:in <code>block in action'
      actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in</code>dispatch'
      actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in</code>block in call'
      actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in</code>call'
      rack-pjax (0.7.0) lib/rack/pjax.rb:12:in <code>call'
      warden (1.2.3) lib/warden/manager.rb:35:in</code>block in call'
      warden (1.2.3) lib/warden/manager.rb:34:in <code>call'
      rack (1.5.2) lib/rack/etag.rb:23:in</code>call'
      rack (1.5.2) lib/rack/conditionalget.rb:35:in <code>call'
      rack (1.5.2) lib/rack/head.rb:11:in</code>call'
      remotipart (1.2.1) lib/remotipart/middleware.rb:27:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in</code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in <code>call'
      rack (1.5.2) lib/rack/session/abstract/id.rb:225:in</code>context'
      rack (1.5.2) lib/rack/session/abstract/id.rb:220:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in</code>call'
      activerecord (4.1.1) lib/active_record/query_cache.rb:36:in <code>call'
      activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in</code>call'
      activerecord (4.1.1) lib/active_record/migration.rb:380:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in</code>block in call'
      activesupport (4.1.1) lib/active_support/callbacks.rb:82:in <code>run_callbacks'
      actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in</code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in</code>call'
      better_errors (1.1.0) lib/better_errors/middleware.rb:84:in <code>protected_app_call'
      better_errors (1.1.0) lib/better_errors/middleware.rb:79:in</code>better_errors_call'
      better_errors (1.1.0) lib/better_errors/middleware.rb:56:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in</code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in <code>call'
      railties (4.1.1) lib/rails/rack/logger.rb:38:in</code>call_app'
      railties (4.1.1) lib/rails/rack/logger.rb:20:in <code>block in call'
      activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in</code>block in tagged'
      activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in <code>tagged'
      activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in</code>tagged'
      railties (4.1.1) lib/rails/rack/logger.rb:20:in <code>call'
      quiet_assets (1.0.2) lib/quiet_assets.rb:18:in</code>call_with_quiet_assets'
      actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in <code>call'
      rack (1.5.2) lib/rack/methodoverride.rb:21:in</code>call'
      rack (1.5.2) lib/rack/runtime.rb:17:in <code>call'
      activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in</code>call'
      rack (1.5.2) lib/rack/lock.rb:17:in <code>call'
      actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in</code>call'
      rack (1.5.2) lib/rack/sendfile.rb:112:in <code>call'
      railties (4.1.1) lib/rails/engine.rb:514:in</code>call'
      railties (4.1.1) lib/rails/application.rb:144:in <code>call'
      rack (1.5.2) lib/rack/content_length.rb:14:in</code>call'
      thin (1.6.2) lib/thin/connection.rb:86:in <code>block in pre_process'
      thin (1.6.2) lib/thin/connection.rb:84:in</code>pre_process'
      thin (1.6.2) lib/thin/connection.rb:53:in <code>process'
      thin (1.6.2) lib/thin/connection.rb:39:in</code>receive_data'
      eventmachine (1.0.3) lib/eventmachine.rb:187:in <code>run'
      thin (1.6.2) lib/thin/backends/base.rb:73:in</code>start'
      thin (1.6.2) lib/thin/server.rb:162:in <code>start'
      rack (1.5.2) lib/rack/handler/thin.rb:16:in</code>run'
      rack (1.5.2) lib/rack/server.rb:264:in <code>start'
      railties (4.1.1) lib/rails/commands/server.rb:69:in</code>start'
      railties (4.1.1) lib/rails/commands/commands_tasks.rb:81:in <code>block in server'
      railties (4.1.1) lib/rails/commands/commands_tasks.rb:76:in</code>server'
      railties (4.1.1) lib/rails/commands/commands_tasks.rb:40:in <code>run_command!'
      railties (4.1.1) lib/rails/commands.rb:17:in</code>'
      bin/rails:8:in <code>&lt;top (required)&gt;'
      ruby-debug-ide (0.4.23.beta1) lib/ruby-debug-ide.rb:86:in</code>debug_program'
      ruby-debug-ide (0.4.23.beta1) bin/rdebug-ide:110:in <code>&lt;top (required)&gt;'
      -e:1:in</code>'</p>
  </blockquote>
  
  <p>Why is it throwing this error? How can I get it to accept the request?</p>