NoMethodError (undefined method `find' for nil:NilClass) with polymorphic belongs_to
jianbo opened this issue · comments
I got this error in my controller after bundle update, can someone confirm this? did I do something wrong?
Thanks
class FlagsController < Api::V1::ResourceController
belongs_to :deal, :polymorphic => true
resources :deals do
resources :comments
resources :images
resources :flags
end
Started POST "/api/v1/deals/56/flags.json?clearence=1" for 192.168.1.56 at 2014-06-11 17:32:56 +1200
Processing by Api::V1::FlagsController#create as JSON
Parameters: {"deal_id"=>"56", "content"=>"asdfad", "auth_token"=>"SoodcyUosyf8ZKY7L7ZN", "clearence"=>"1", "flag"=>{"content"=>"test"}}
Roll back to version 1.4.1 works.
@rohitpaulk add parent class works for me! Thank you!
@phlegx - You're welcome!
@rohitpaulk polymorphic: true
in your example doesn't have much sense, because you have only one possible parent association.
module Admin
class PositionsController < BaseController
belongs_to :employee, :assignment, polymorphic: true
end
end
In this case you can't use parent_class
option to point to the correct parent class
@bronislav - True :) I had just copied the OP's code and added the parent class part.
Could you check with current master? It may be fixed by #376