rails/rails — Issue #4674: Rails 3.2 Namespaced models which share class names create new record instances with wrong attributes
Author: nickflux
Created: 2012-01-25 19:03:44+00:00
State: open

I have two classes:

```ruby
class ChartType < ActiveRecord::Base

end

module Import::Billboard
class ChartType < ActiveRecord::Base

end
end
```
The tables have different columns.

If, in the console, I call Import::Billboard::ChartType.first.attributes, it returns
```ruby
{"id"=>6,
"chart_type"=>"Chart Type",
"feed_name"=>"The Feed Name",
"feed_code"=>"field missing"}
```
But if I call Import::Billboard::ChartType.new.attributes, it returns
```ruby
{"id"=>nil,
"chart_type"=>nil,
"chart_source"=>nil,
"chart_type_importable_id"=>nil,
"chart_type_importable_type"=>nil,
"created_at"=>nil,
"updated_at"=>nil,
"feed_name"=>nil,
"feed_code"=>nil
```

Which is the attribute list for the non-namespaced ChartType class. I can call Import::Billboard::ChartFile.new.attributes, which has no non-namespaced counterpart, and the correct list of attributes is returned. This problem is new in Rails 3.2