Dynamic Paths in Helper

basically you need to transform the class name of the model into something pointing to the correct path.

model_name = m.class.to_s.underscore

And then use it to call the appropriate path methods

link_to "edit", send("edit_#{model_name}_path", m)

As an aside, you don’t need to put the link_tos in #{} because that function simply returns a string.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)