So I want to dynamically have new_course_discussion_path(@discussable) or new_group_discussion_path(@discussable) depending on the @discussable class type. How do I pass the message (@discussable) in to this method? I tried:
"new_#{@discussable.class.to_s.downcase}_discussion_path".constantize(@discussable)
but this says “wrong number of arguments (1 for 0)”. I’m new to rails. Please help! Thanks.
Update:
Right now, the whole line is
= link_to '>New Discussion', "new_#{@discussable.class.to_s.downcase}_discussion_path".constantize(@discussable)
The path helpers are methods not classes. They’re accessible from controllers, views and helper methods and if you don’t qualify the
sendcall, it will invoke the method on self.