# Single inheritance with nested attributes routing problem

**URL:** <https://www.ruby-forum.com/t/single-inheritance-with-nested-attributes-routing-problem/178272>\
**Category:** Rails\
**Created:** [November 1, 2009, 8:39pm UTC](https://www.ruby-forum.com/t/single-inheritance-with-nested-attributes-routing-problem/178272 "2009-11-01T20:39:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![james-calivar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@james-calivar](https://www.ruby-forum.com/u/james-calivar)\
**Post date:** [November 1, 2009, 8:39pm UTC](https://www.ruby-forum.com/t/single-inheritance-with-nested-attributes-routing-problem/178272/1 "2009-11-01T20:39:33Z")

</div>

I am working on a project that involves many different types of users,  
each with their own sets of information. I decided to condense the  
variety of users into a single class to deal with things like logging  
into the site, and use single table inheritance to account for the rest  
of the logic. Since the different user types require different  
information I made new models to store this extra information, linking  
them back into the relevant classes with has\_many and belongs\_to.

The trouble comes up when I try to load a form creating a new user and  
their information. I receive this error:

```
uninitialized constant BasicUser::BaseDetail

```

The parts of code I think might be relevant are:

* * *

#user.rb  
class User \< ActiveRecord::Base  
end

#basic\_user.rb  
class BasicUser \< User  
has\_one :details, :class\_name =\> ‘BaseDetail’, :foreign\_key =\>  
“user\_id”  
accepts\_nested\_attributes\_for :details, :allow\_destroy =\> true  
end

#basic\_detail.rb  
class BasicDetail \< ActiveRecord::Base  
belongs\_to :basic\_user  
end

#routes.rb  
map.resources :basic\_users, :controller =\> ‘user’  
map.resources :users

#register.html  
\<% form\_for @user do |user| %\>  
\<% fields\_for @user.details do |details| %\>  
#some form stuff  
\<% end %\>  
#more form stuff  
\<% end %\>

## #home\_controller.rb def register if !param\_exists? :user @user = BasicUser.new end if param\_posted? :user @user = BasicUser.new(params[:user]) if @user.save redirect\_to :controller =\> “user” end end end

I’ve been working with Rails 1.2.6 up until now (I wanted to use  
accepts\_nested\_attributes\_for) and so this is my first day with the new  
version. I have very little understanding of routes, and indeed the only  
reason I have them there at all is because without them I get the error  
“undefined method `basic\_users\_path’ for #ActionView::Base:0x5a51db0.”

On a similar note, rails has become much slower since I updated to  
2.3.5. Can this be fixed, or is it probably just my computer being  
worthless?

Thanks  
-Jaheco

---

<div class="post-metadata">

**Author:** ![james-calivar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@james-calivar](https://www.ruby-forum.com/u/james-calivar)\
**Post date:** [November 1, 2009, 9:00pm UTC](https://www.ruby-forum.com/t/single-inheritance-with-nested-attributes-routing-problem/178272/2 "2009-11-01T21:00:04Z")

</div>

You have a naming mismatch between “BaseDetail” and “BasicDetail”

On Nov 1, 1:39 pm, James C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![james-calivar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@james-calivar](https://www.ruby-forum.com/u/james-calivar)\
**Post date:** [November 1, 2009, 9:28pm UTC](https://www.ruby-forum.com/t/single-inheritance-with-nested-attributes-routing-problem/178272/3 "2009-11-01T21:28:26Z")

</div>

This… is true… I am an idiot.

Thank you.
