Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 - has_many through with nested form
    primarykey
    data
    text
    <p>I am trying to use a nested form but keep getting this error when saving -</p> <pre><code>uninitialized constant User::Userplan </code></pre> <p>Here is my model code -</p> <p>User</p> <pre><code>class User &lt; ActiveRecord::Base has_many :userplans has_many :plans, :through =&gt; :userplans accepts_nested_attributes_for :userplans </code></pre> <p>UserPlan</p> <pre><code>class UserPlan &lt; ActiveRecord::Base belongs_to :plan belongs_to :user </code></pre> <p>Plan</p> <pre><code>class Plan &lt; ActiveRecord::Base has_many :userplans has_many :users, :through =&gt; :userplans </code></pre> <p>Form</p> <pre><code>&lt;%= form_for(@user) do |f| %&gt; &lt;%= hidden_field_tag "user[userplans][plan_id]", 2 %&gt; &lt;%= f.text_field :first_name %&gt;&lt;/p&gt; </code></pre> <p>I know using a hidden_field_tag is wrong but im not sure of a better way</p> <p>Thanks for any help!</p> <p>activerecord (3.0.3) lib/active_record/associations/association_proxy.rb:260:in <code>raise_on_type_mismatch' activerecord (3.0.3) lib/active_record/associations/association_collection.rb:352:in</code>block in replace' activerecord (3.0.3) lib/active_record/associations/association_collection.rb:352:in <code>each' activerecord (3.0.3) lib/active_record/associations/association_collection.rb:352:in</code>replace' activerecord (3.0.3) lib/active_record/associations.rb:1524:in <code>block in collection_accessor_methods' activerecord (3.0.3) lib/active_record/base.rb:1559:in</code>block in attributes=' activerecord (3.0.3) lib/active_record/base.rb:1555:in <code>each' activerecord (3.0.3) lib/active_record/base.rb:1555:in</code>attributes=' cancan (1.4.1) lib/cancan/controller_resource.rb:72:in <code>build_resource' cancan (1.4.1) lib/cancan/controller_resource.rb:48:in</code>load_resource_instance' cancan (1.4.1) lib/cancan/controller_resource.rb:30:in <code>load_resource' cancan (1.4.1) lib/cancan/controller_resource.rb:24:in</code>load_and_authorize_resource' cancan (1.4.1) lib/cancan/controller_resource.rb:9:in <code>block in add_before_filter' activesupport (3.0.3) lib/active_support/callbacks.rb:436:in</code><em>run</em>_3988671192319902872__process_action_<em>982103756142273942</em>_callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:409:in <code>_run_process_action_callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:93:in</code>run_callbacks' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in <code>process_action' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:in</code>block in process_action' activesupport (3.0.3) lib/active_support/notifications.rb:52:in <code>block in instrument' activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in</code>instrument' activesupport (3.0.3) lib/active_support/notifications.rb:52:in <code>instrument' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in</code>process_action' actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in <code>process_action' actionpack (3.0.3) lib/abstract_controller/base.rb:120:in</code>process' actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in <code>process' actionpack (3.0.3) lib/action_controller/metal.rb:138:in</code>dispatch' actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in <code>dispatch' actionpack (3.0.3) lib/action_controller/metal.rb:178:in</code>block in action' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in <code>call' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in</code>dispatch' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in <code>call' rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in</code>block in call' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in <code>block in recognize' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:75:in</code>optimized_each' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in <code>recognize' rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in</code>call' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in <code>call' warden (1.0.2) lib/warden/manager.rb:35:in</code>block in call' warden (1.0.2) lib/warden/manager.rb:34:in <code>catch' warden (1.0.2) lib/warden/manager.rb:34:in</code>call' actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in <code>call' actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in</code>call' rack (1.2.1) lib/rack/methodoverride.rb:24:in <code>call' actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in</code>call' actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:in <code>call' actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in</code>call' actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in <code>call' activerecord (3.0.3) lib/active_record/query_cache.rb:32:in</code>block in call' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in <code>cache' activerecord (3.0.3) lib/active_record/query_cache.rb:12:in</code>cache' activerecord (3.0.3) lib/active_record/query_cache.rb:31:in <code>call' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in</code>call' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:in <code>block in call' activesupport (3.0.3) lib/active_support/callbacks.rb:415:in</code>_run_call_callbacks' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in <code>call' rack (1.2.1) lib/rack/sendfile.rb:107:in</code>call' actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in <code>call' actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in</code>call' railties (3.0.3) lib/rails/rack/logger.rb:13:in <code>call' rack (1.2.1) lib/rack/runtime.rb:17:in</code>call' activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in <code>call' rack (1.2.1) lib/rack/lock.rb:11:in</code>block in call' :10:in <code>synchronize' rack (1.2.1) lib/rack/lock.rb:11:in</code>call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in <code>call' railties (3.0.3) lib/rails/application.rb:168:in</code>call' railties (3.0.3) lib/rails/application.rb:77:in <code>method_missing' railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in</code>call' rack (1.2.1) lib/rack/content_length.rb:13:in <code>call' rack (1.2.1) lib/rack/handler/webrick.rb:52:in</code>service' /Users/joshcrowder/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:111:in <code>service' /Users/joshcrowder/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:70:in</code>run' /Users/joshcrowder/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'</p>
    singulars
    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.
    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