Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
demo app to describe my problem with InheritedResources using polymorphic associations
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
db
doc
lib/tasks
public
script
test
vendor/plugins
.gitignore
Gemfile
Gemfile.lock
README
Rakefile
config.ru

README

demo app to describe my problem with InheritedResources using polymorphic associations

- bundle install
- rake db:migrate (this will also add dummy values)
- bundle exec unicorn_rails -p 3000


go to 
 http://localhost:3000/employees/1/pictures

you will see: Parent = nil

open app/controllers/pictures_controller.rb 

replace 
  belongs_to :employee, :product, :polymorphic => true

with 
  belongs_to :employee 

go back again to 
  http://localhost:3000/employees/1/pictures

You will see
Parent = #<Employee id: 1, name: "employe1", created_at: "2011-08-16 08:07:42", updated_at: "2011-08-16 08:07:42">

I believe that shows the association and logic works fine with a regular "belongs_to" but not with ":polymorphic => true"


I don't know if I missed a configuration option or if there is a bug, absolutely everything else is working perfeclty with InheritedResources in my application, of course I have tried to digg the gem's code, ran the tests, read the documentation, posted my question on the google group, stackoverflow and github....

Thanks in advance for any help, my last resort would be to record a holographic message, upload into a droid and send him through space to look for Obi-Wan Kenobi but I'm not sure how to do that either.

cheers

julien



Github ticket:
https://github.com/josevalim/inherited_resources/issues/158

Stackoverflow question:
http://stackoverflow.com/questions/5907450/inherited-resources-cant-get-the-parent-in-a-polymorphic-belongs-to

Google group thread:
http://groups.google.com/group/inherited_resources/browse_thread/thread/8d154492bad90f2d?pli=1
Something went wrong with that request. Please try again.