Note that there are some explanatory texts on larger screens.

plurals
  1. POactivescaffold belongs_to relationship giving routing error
    text
    copied!<p>I am using the following: Rails 3.0.3 Vhochstein's Fork for Activescaffold rake 0.9.0 ruby 1.9.2</p> <p>I have a model called component which has a belongs_to relationship with category. This was modelled using activescaffold and was working quite well. I took a break for a couple of months and now that I got back to it activescafold gives a "ActionController::RoutingError (undefined method `class_name' for nil:NilClass):" error whenever I try to access the component model. I figured this is due to the relationship (belongs_to). If i remove the relationship from the model, it works. If I add it back it fails!</p> <p>Any Ideas?</p> <p>Here is the Code:</p> <h2>Routes</h2> <pre><code> namespace :admin do resources :users,:roles,:vendors,:shipping_modes,:order_types,:sizes, :suppliers,:categories,:sub_categories, :material_types,:colours, :materials,:styles,:surcharges, :budget_templates, :budget_components do as_routes end </code></pre> <p>end</p> <h2>Controller</h2> <pre><code>class Admin::BudgetComponentsController &lt; ApplicationController layout 'site_admin' active_scaffold :budget_component do |config| config.actions.exclude :delete,:update config.columns[:category].form_ui = :select config.create.columns = [:name,:category] config.list.columns = [:name,:category] config.show.columns = [:name,:category] config.show.columns.add_subgroup "Time Details" do |name_group| name_group.add :created_at,:updated_at end config.list.sorting = {:name =&gt; 'ASC'} end end </code></pre> <h2>Model</h2> <pre><code>class BudgetComponent &lt; ActiveRecord::Base belongs_to :category validates_presence_of :name, :category_id validates_uniqueness_of :name end </code></pre>
 

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