When incorporating AJAX into my Rails application, I encounter difficulties when specifying the URL for the request within a script. While it is recommended to use helpers like my_resource_path
instead of manually writing paths, these helpers do not function properly within assets/javascripts
. As a result, I have had to resort to using inefficient workarounds such as embedding code in my views:
<%= javascript_tag "onSubmitQuotePage('#{j escape_javascript(autocomplete_authors_url(''))}');"%>
Surely there must be a more elegant solution or best practice for handling AJAX requests in Rails applications.