randombits
randombits

Reputation: 48460

JavaScript template for a HAML based view

I have a Ruby on Rails application that is using HAML based template views. I need to drop a simple:

alert('Hello World'); JavaScript excerpt template that I can build off that loads for the page.

If my controller's name is Foo and my actions name is bar, I put a bar.js.haml into app/views/foo/ and it doesn't seem to load any of that JS when I load the page up.

What can I do to debug this and get JavaScript embedded into my haml views?

Upvotes: 1

Views: 1004

Answers (1)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

Right, it's not going to auto include or auto reference another script for you. If you want to add javascript to the page using HAML:

:javascript
  alert('Hellooooooooooo');

Update with way to link to javascript file named "bar.js" in app/assets/javascripts

= javascript_include_tag "bar"

Upvotes: 1

Related Questions