I’m trying to use a polymorphic_path but am getting an error:
“undefined method `model_name’ for Fixnum:Class”
When using:
<%= link_to ‘Here she is’, polymorphic_path([audited_id,
audited_type]) %>
you have to pass 2 objects to polymorphic_path(parent_model_object,
object) , audited_id is a number , that is what Fixnum:Class means,
polymorphic path assembles a helper method like this,
polumorphic_path(audit.auditable, audit ) =====> takes the first
object passed as audit.auditable, because auditable is the alias for the
parent model, so in your case is trying to get the model out of that
first
parameter which is a number, when it should be instance of Photo or
comment,
so it can create this => photo_audit_path , you see? this happens if
you
pass an instance of the parent model and then the instance of the
polymorphic model.
you are passing a number and a string, auditer_id is a number and
audited_type is a string.
Ah shoot, I think the reason it wasn’t working is I had some records
in the table that were empty for the polymorphic assoc… I guess it
fails if it’s blank… thank you!