I am using the following: Rails 3.0.3 Vhochstein's Fork for Activescaffold rake 0.9.0 ruby 1.9.2
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开发者_如何学Python relationship from the model, it works. If I add it back it fails!
Any Ideas?
Here is the Code:
Routes
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
end
Controller
class Admin::BudgetComponentsController < 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 => 'ASC'}
end
end
Model
class BudgetComponent < ActiveRecord::Base
belongs_to :category
validates_presence_of :name, :category_id
validates_uniqueness_of :name
end
I had a similar problem. The solution is to add your nil:NilClass
again, then it will work.
精彩评论