50 Experience
0 Lessons Completed
0 Questions Solved


Hey guys, trying to do a pretty simple thing but all the information I can find online (for "beginners") seems to omit some core things I'm expected to know, because it doesn't even do so much as throw an error. Rails 5.2

I just want to change the text of my button on click.

I have a standard button_to
    <%= button_to "Unsave", resource_path(id:, remote: true, method: :delete, class: "save_btn", id: "save_btn"%>

I have saved the following to "" in my javascripts folder
$ ->
  $(".save_btn").on "ajax:success", (e, data, status, xhr) ->

In my application.html.erb layout I am loading my JS
    <script src="//"></script>
    <%= stylesheet_link_tag    'application', media: 'all',
                                              'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'resources', 'data-turbolinks-track': 'reload' %>

Rails threw me an error and instructed me to insert this into assets.rb, which I have done
Rails.application.config.assets.precompile += %w( resources.js )

Nothing happens to the button when I click it. Can somebody please fill in the blanks for me? I have no javascript experience and I am pretty sure I am missing something to the equivalent of "Is it plugged in?".
logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.