Reputation: 3211
In my template I'm trying to dynamically define the path helper inside:
<%= link "Edit", to: @options[:resource]_path(@options[:conn], :edit, @options[:resource]) %>
So, I would like to use @options[:resource]
to prepend the resource name and create the correct path helper, like: post_path(@conn, :edit, post)
As this is a function name and not a string all methods I've tried (#{}, <>, ++
) don't work.
Upvotes: 1
Views: 72
Reputation: 121000
Since you want to dynamically call the function, Kernel#apply/3
should help here:
<%= link "Edit", to: apply(
__MODULE__,
:"#{@options[:resource]}_path",
[@options[:conn], :edit, @options[:resource]]
) %>
Upvotes: 1