You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The line: resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource fails because the parent_resource in a polymorphic association is not post but commentable=. Therefore, we get the error:
NoMethodError:
undefined method `post=' for #<Comment
Expected behavior
I can instantiate a polymorphic association correctly.
Actual behavior
I get an undefined method error.
System configuration
Rails version:
7.0.7 Ruby version:
3.2.2. CanCanCan version
3.5
The text was updated successfully, but these errors were encountered:
ccfz
changed the title
Creating resource failes when association is polymorphic and singlton.
Creating resource failes when association is polymorphic and singleton.
Aug 15, 2023
Steps to reproduce
Given I have the following association:
and the following controller:
I ran into a problem when building the resource and assigning the attributes here.
The line:
resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource
fails because the parent_resource in a polymorphic association is notpost
butcommentable=
. Therefore, we get the error:Expected behavior
I can instantiate a polymorphic association correctly.
Actual behavior
I get an
undefined method
error.System configuration
Rails version:
7.0.7
Ruby version:
3.2.2.
CanCanCan version
3.5
The text was updated successfully, but these errors were encountered: