Note that there are some explanatory texts on larger screens.

plurals
  1. PORails ArgumentError (wrong number of arguments (0 for 1)) during insert
    primarykey
    data
    text
    <p>Using Rails 3.2.0.rc2 and ruby 1.9.3p0</p> <p>I have a quotes table with the following schema:</p> <pre><code>CREATE TABLE "quotes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "quote_value" float, "quote_note" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); </code></pre> <p>When I create a new quote via <a href="http://localhost:3000/quotes/new" rel="nofollow">http://localhost:3000/quotes/new</a>, I get the error</p> <pre><code>wrong number of arguments (0 for 1) </code></pre> <p>and </p> <pre><code>app/controllers/quotes_controller.rb:47:in `block in create' app/controllers/quotes_controller.rb:45:in `create' </code></pre> <p>The following is from development.log</p> <pre><code> Started POST "/quotes" for 127.0.0.1 at 2012-01-10 18:58:11 +0100 Processing by QuotesController#create as HTML Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"3l5KzYrwIOf84P3Y4JF1/iV1Sx+Uf4rfq3y6iUUinSw=", "quote"=&gt;{"quote_value"=&gt;"1", "quote_note"=&gt;"hello"}, "commit"=&gt;"Create Quote"} quote is : #&lt;Quote:0x324bbb8&gt; (0.1ms) begin transaction SQL (5.8ms) INSERT INTO "quotes" ("created_at", "quote_note", "quote_value", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 10 Jan 2012 17:58:11 UTC +00:00], ["quote_note", "hello"], ["quote_value", "1"], ["updated_at", Tue, 10 Jan 2012 17:58:11 UTC +00:00]] (0.5ms) rollback transaction Completed 500 Internal Server Error in 8ms ArgumentError (wrong number of arguments (0 for 1)): app/controllers/quotes_controller.rb:47:in `block in create' app/controllers/quotes_controller.rb:45:in `create' </code></pre> <p>Any ideas why this is happening? Is it because of the formatted values in the Insert query?</p> <p>Thanks</p> <p>Update: The quotes_controller.rb file</p> <pre><code>class QuotesController &lt; ApplicationController # GET /quotes # GET /quotes.json def index @quotes = Quote.all respond_to do |format| format.html # index.html.erb format.json { render json: @quotes } end end # GET /quotes/1 # GET /quotes/1.json def show @quote = Quote.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @quote } end end # GET /quotes/new # GET /quotes/new.json def new @quote = Quote.new respond_to do |format| format.html # new.html.erb format.json { render json: @quote } end end # GET /quotes/1/edit def edit @quote = Quote.find(params[:id]) end # POST /quotes # POST /quotes.json def create @quote = Quote.new(params[:quote]) respond_to do |format| if @quote.save format.html { redirect_to @quote, notice: 'Quote was successfully created.' } format.json { render json: @quote, status: :created, location: @quote } else format.html { render action: "new" } format.json { render json: @quote.errors, status: :unprocessable_entity } end end end # PUT /quotes/1 # PUT /quotes/1.json def update @quote = Quote.find(params[:id]) respond_to do |format| if @quote.update_attributes(params[:quote]) format.html { redirect_to @quote, notice: 'Quote was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @quote.errors, status: :unprocessable_entity } end end end # DELETE /quotes/1 # DELETE /quotes/1.json def destroy @quote = Quote.find(params[:id]) @quote.destroy respond_to do |format| format.html { redirect_to quotes_url } format.json { head :no_content } end end end </code></pre> <p>Update 2: added models</p> <pre><code>class Request &lt; ActiveRecord::Base validates :cust_email, :presence =&gt; true has_many :quotes, :dependent =&gt; :destroy has_many :brokers, :through =&gt; :quotes end class Broker &lt; ActiveRecord::Base has_many :quotes, :dependent =&gt; :destroy has_many :requests, :through =&gt; :quotes end class Quote &lt; ActiveRecord::Base belongs_to :broker belongs_to :request end </code></pre> <p>Update 3: The following is the Full Trace</p> <pre><code>vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/sanitization.rb:190:in `quote_value' vendor/bundle/gems/activemodel-3.2.0.rc2/lib/active_model/dirty.rb:143:in `attribute_change' vendor/bundle/gems/activemodel-3.2.0.rc2/lib/active_model/dirty.rb:117:in `block in changes' vendor/bundle/gems/activemodel-3.2.0.rc2/lib/active_model/dirty.rb:117:in `map' vendor/bundle/gems/activemodel-3.2.0.rc2/lib/active_model/dirty.rb:117:in `changes' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/attribute_methods/dirty.rb:23:in `save' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:241:in `block (2 levels) in save' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:190:in `transaction' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:208:in `transaction' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:293:in `with_transaction_returning_status' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:241:in `block in save' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:252:in `rollback_active_record_state!' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/transactions.rb:240:in `save' app/controllers/quotes_controller.rb:50:in `block in create' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/mime_responds.rb:269:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/mime_responds.rb:269:in `retrieve_response_from_mimes' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/mime_responds.rb:194:in `respond_to' app/controllers/quotes_controller.rb:45:in `create' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/implicit_render.rb:4:in `send_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/abstract_controller/base.rb:167:in `process_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/rendering.rb:10:in `process_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/abstract_controller/callbacks.rb:18:in `block in process_action' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:414:in `_run__798983255__process_action__126235889__callbacks' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:405:in `__run_callback' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:81:in `run_callbacks' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/abstract_controller/callbacks.rb:17:in `process_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/rescue.rb:29:in `process_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/notifications.rb:119:in `block in instrument' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/notifications/instrumenter.rb:20:in `instrument' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/notifications.rb:119:in `instrument' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/instrumentation.rb:29:in `process_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/params_wrapper.rb:205:in `process_action' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/railties/controller_runtime.rb:18:in `process_action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/abstract_controller/base.rb:121:in `process' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/abstract_controller/rendering.rb:45:in `process' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal.rb:199:in `dispatch' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_controller/metal.rb:242:in `block in action' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/routing/route_set.rb:66:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/routing/route_set.rb:66:in `dispatch' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/routing/route_set.rb:30:in `call' vendor/bundle/gems/journey-1.0.0.rc4/lib/journey/router.rb:60:in `block in call' vendor/bundle/gems/journey-1.0.0.rc4/lib/journey/router.rb:48:in `each' vendor/bundle/gems/journey-1.0.0.rc4/lib/journey/router.rb:48:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/routing/route_set.rb:570:in `call' vendor/bundle/bundler/gems/omniauth-966a4653a5fd/lib/omniauth/strategy.rb:168:in `call!' vendor/bundle/bundler/gems/omniauth-966a4653a5fd/lib/omniauth/strategy.rb:148:in `call' vendor/bundle/bundler/gems/omniauth-966a4653a5fd/lib/omniauth/builder.rb:28:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/etag.rb:23:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/conditionalget.rb:35:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/head.rb:14:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/params_parser.rb:21:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/flash.rb:242:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:205:in `context' vendor/bundle/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:200:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/cookies.rb:338:in `call' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/query_cache.rb:64:in `call' vendor/bundle/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:405:in `_run__429521786__call__490392356__callbacks' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:405:in `__run_callback' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/callbacks.rb:81:in `run_callbacks' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/callbacks.rb:27:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/reloader.rb:63:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' vendor/bundle/gems/railties-3.2.0.rc2/lib/rails/rack/logger.rb:26:in `call_app' vendor/bundle/gems/railties-3.2.0.rc2/lib/rails/rack/logger.rb:16:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/request_id.rb:22:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/methodoverride.rb:21:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/runtime.rb:17:in `call' vendor/bundle/gems/activesupport-3.2.0.rc2/lib/active_support/cache/strategy/local_cache.rb:72:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/lock.rb:15:in `call' vendor/bundle/gems/actionpack-3.2.0.rc2/lib/action_dispatch/middleware/static.rb:53:in `call' vendor/bundle/gems/railties-3.2.0.rc2/lib/rails/engine.rb:479:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/content_length.rb:14:in `call' vendor/bundle/gems/railties-3.2.0.rc2/lib/rails/rack/log_tailer.rb:14:in `call' vendor/bundle/gems/rack-1.4.0/lib/rack/handler/webrick.rb:59:in `service' /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload