.erb file is processed once when it is rendered to the page.
All the path helpers are available so just once, you can't call a rails helper(or any other rails code) from client side unless you made a separate ajax call.
So, In this case your options are:
- Store the path in some
attr
in the#question
div itself and fetch it in js function. - Store path in js array/hash , maintain them and use it appropriately
- Modify your routes to have questions_path as
collection
instead of onmember
like/question?id=5
instead ofquestion/5/
, in that case you can add query parameterid
in your js function your self andquestions_path
will return you/question