Note that there are some explanatory texts on larger screens.

plurals
  1. PORails undefined method `model_name' in form partial
    primarykey
    data
    text
    <p>I have this model:</p> <pre><code>class ToType &lt; ActiveRecord::Base attr_accessible :Name, :TYP_CCM, :TYP_CCM_TAX, :TYP_CDS_ID, :TYP_CTM, :TYP_CYLINDERS, :TYP_DOORS, :TYP_HP_FROM, :TYP_HP_UPTO, :TYP_ID, :TYP_KV_ABS_DES_ID, :TYP_KV_ASR_DES_ID, :TYP_KV_AXLE_DES_ID, :TYP_KV_BODY_DES_ID, :TYP_KV_BRAKE_SYST_DES_ID, :TYP_KV_BRAKE_TYPE_DES_ID, :TYP_KV_CATALYST_DES_ID, :TYP_KV_DRIVE_DES_ID, :TYP_KV_ENGINE_DES_ID, :TYP_KV_FUEL_DES_ID, :TYP_KV_FUEL_SUPPLY_DES_ID, :TYP_KV_MODEL_DES_ID, :TYP_KV_STEERING_DES_ID, :TYP_KV_STEERING_SIDE_DES_ID, :TYP_KV_TRANS_DES_ID, :TYP_KV_VOLTAGE_DES_ID, :TYP_KW_FROM, :TYP_KW_UPTO, :TYP_LA_CTM, :TYP_LITRES, :TYP_MAX_WEIGHT, :TYP_MMT_CDS_ID, :TYP_MOD_ID, :TYP_PCON_END, :TYP_PCON_START, :TYP_RT_EXISTS, :TYP_SORT, :TYP_TANK, :TYP_VALVES, :is_in_to set_primary_key :TYP_ID belongs_to :to_model has_many :to_articles, :foreign_key =&gt; "to_type_id", :dependent =&gt; :destroy end class ToArticle &lt; ActiveRecord::Base attr_accessible :details, :manufacturer, :name, :oem_number, :only_with_vin, :quantity, :to_type_id belongs_to :to_type, :foreign_key =&gt; "TYP_ID" belongs_to :to_engine end </code></pre> <p>(some db is converted from big catalog, so rails conventions are slightly imperfect)</p> <p>Part of my show view of to_type: </p> <pre><code>%td = link_to "Подробнее", admin_catalog_to_to_article_path(c), :class=&gt;'btn btn-primary' = link_to "Редактирование", edit_admin_catalog_to_to_type_path(c), :class=&gt;'btn btn-warning' = link_to "Удалить", admin_catalog_to_to_type_path(c), :confirm =&gt; "!!!Тип #{c.Name} будет удалён!!!! Вы уверены?", :method =&gt; :delete, :class =&gt; "btn btn-danger" </code></pre> <p>my show action works normally same for my controller:</p> <pre><code>class Admin::Catalog::To::ToTypesController &lt; ApplicationController respond_to :html before_filter :auth_user def auth_user redirect_to new_admin_session_path unless admin_signed_in? end def show @mod_id = params[:id] @man = ToType.find(:all, conditions: {:TYP_MOD_ID =&gt; @mod_id}, order: "Name ASC") render :layout =&gt; 'admin' end def edit @man = ToType.find(params[:id]) render :layout =&gt; 'admin' end def update @man = ToType.find(params[:id]) if @mod.update_attributes(params[:to_type]) redirect_to admin_catalog_to_to_type_path(@man.TYP_MOD_ID) else render :layout =&gt; 'admin' end end def new @man = ToType.new @mod_id = params[:mod_id] render :layout =&gt; 'admin' end def create @man = ToType.new(params[:to_type]) @mod_id = params[:mod_id] @man.TYP_MOD_ID = @mod_id if @man.save redirect_to admin_catalog_to_to_type_path(@mod_id) else render :layout =&gt; 'admin' end end def destroy @man = ToType.find(params[:id]) if @man.destroy redirect_to admin_catalog_to_to_type_path(@man.TYP_MOD_ID) else render :layout =&gt; 'admin' end end end and route: namespace :admin do namespace :catalog do namespace :to do resources :to_manufacturers, :to_models, :to_types, :to_articles end end end </code></pre> <p>form partial:</p> <pre><code>= form_for [:admin, :catalog, :to, @man] do |f| = f.label :id ... </code></pre> <p>When I try edit or create I get:</p> <pre><code>undefined method `model_name' for NilClass:Class </code></pre> <p>I think that something is wrong with connection with model: with update and create. In the log I see that the object is founded in db for edit for example, and in the log I can see that @man is not empty, but I still get <code>undefined method</code>model_name' for NilClass:Class` . Why?</p> <p><strong>upd</strong>: Full trace</p> <pre><code> NoMethodError in Admin/catalog/to/to_types#edit Showing /media/sf__Projects/Denis/app/views/admin/catalog/to/to_types/_edit.html.haml where line #1 raised: undefined method `model_name' for NilClass:Class Extracted source (around line #1): 1: = form_for [:admin, :catalog, :to, @man] do |f| 2: = f.label :id Trace of template inclusion: app/views/admin/catalog/to/to_types/edit.html.haml Rails.root: /media/sf__Projects/Denis Application Trace | Framework Trace | Full Trace activemodel (3.2.8) lib/active_model/naming.rb:163:in `model_name_from_record_or_class' activemodel (3.2.8) lib/active_model/naming.rb:158:in `param_key' actionpack (3.2.8) lib/action_view/helpers/form_helper.rb:369:in `form_for' haml (4.0.3) lib/haml/helpers/action_view_mods.rb:146:in `form_for_with_haml' haml (4.0.3) lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss' app/views/admin/catalog/to/to_types/_edit.html.haml:1:in `_app_views_admin_catalog_to_to_types__edit_html_haml___4584370517694291299_51970960' actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render' activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument' actionpack (3.2.8) lib/action_view/template.rb:143:in `render' actionpack (3.2.8) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial' actionpack (3.2.8) lib/action_view/renderer/partial_renderer.rb:238:in `block in render' actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' actionpack (3.2.8) lib/action_view/renderer/partial_renderer.rb:237:in `render' actionpack (3.2.8) lib/action_view/renderer/renderer.rb:41:in `render_partial' actionpack (3.2.8) lib/action_view/helpers/rendering_helper.rb:27:in `render' haml (4.0.3) lib/haml/helpers/action_view_mods.rb:10:in `block in render_with_haml' haml (4.0.3) lib/haml/helpers.rb:89:in `non_haml' haml (4.0.3) lib/haml/helpers/action_view_mods.rb:10:in `render_with_haml' app/views/admin/catalog/to/to_types/edit.html.haml:7:in `_app_views_admin_catalog_to_to_types_edit_html_haml___2140731807560860717_28965400' actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render' activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument' actionpack (3.2.8) lib/action_view/template.rb:143:in `render' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template' actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:45:in `render_template' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:18:in `render' actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template' actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render' actionpack (3.2.8) lib/abstract_controller/rendering.rb:110:in `_render_template' actionpack (3.2.8) lib/action_controller/metal/streaming.rb:225:in `_render_template' actionpack (3.2.8) lib/abstract_controller/rendering.rb:103:in `render_to_body' actionpack (3.2.8) lib/action_controller/metal/renderers.rb:28:in `render_to_body' actionpack (3.2.8) lib/action_controller/metal/compatibility.rb:50:in `render_to_body' actionpack (3.2.8) lib/abstract_controller/rendering.rb:88:in `render' actionpack (3.2.8) lib/action_controller/metal/rendering.rb:16:in `render' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `block in ms' /home/pavel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/benchmark.rb:295:in `realtime' activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `ms' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block in render' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime' activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:39:in `render' app/controllers/admin/catalog/to/to_types_controller.rb:18:in `edit' actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action' actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action' activesupport (3.2.8) lib/active_support/callbacks.rb:447:in `_run__3422493215220642812__process_action__1624115620138968240__callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action' actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action' activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process' actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process' actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch' actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call' journey (1.0.4) lib/journey/router.rb:68:in `block in call' journey (1.0.4) lib/journey/router.rb:56:in `each' journey (1.0.4) lib/journey/router.rb:56:in `call' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call' warden (1.2.1) lib/warden/manager.rb:35:in `block in call' warden (1.2.1) lib/warden/manager.rb:34:in `catch' warden (1.2.1) lib/warden/manager.rb:34:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' rack (1.4.5) lib/rack/etag.rb:23:in `call' rack (1.4.5) lib/rack/conditionalget.rb:25:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call' rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context' rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call' activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__2440713806940417433__call__2360308109704352565__callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app' railties (3.2.8) lib/rails/rack/logger.rb:16:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call' rack (1.4.5) lib/rack/methodoverride.rb:21:in `call' rack (1.4.5) lib/rack/runtime.rb:17:in `call' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call' rack (1.4.5) lib/rack/lock.rb:15:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call' railties (3.2.8) lib/rails/engine.rb:479:in `call' railties (3.2.8) lib/rails/application.rb:223:in `call' rack (1.4.5) lib/rack/content_length.rb:14:in `call' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call' rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service' /home/pavel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' /home/pavel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' /home/pavel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' Request Parameters: {"id"=&gt;"28752"} Show session dump Show env dump Response Headers: None </code></pre>
    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.
 

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