Sunday, August 11, 2013

Rails default JS files in application.html.erb to avoid defaults.js 404 error

Although Rails cannot let you post a DELETE action, it can pretend to do so with javascript. JQuery is the default js lib of choice for what I've studied so far, and in this post, a simple change in the application.html.erb allows my js file to be called correctly.

My Gemfile does have:
gem 'jquery-rails'

I tried updating my application.rb with a config.action_view.javascript_expansions[:defaults] = %w(jquery rails), but that caused Zeus to puke. No good :(

Instead, I made a slight change to my application.html.erb and was able to now magically have JS destroy for me (WIN!).

<%= javascript_include_tag "application %>

did the trick!

No comments:

Post a Comment