You have a naming mismatch between "BaseDetail" and "BasicDetail"

On Nov 1, 1:39 pm, James Cook <rails-mailing-l...@andreas-s.net>
wrote:
> 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
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to