0

I have a view with the following namespace

view/kids/registration/new.html.haml

Now I need to create a js file to this view, so I created a file in the following path:

assets/javascripts/kids/registration/new.js

Then I add the following lines to the application.js:

//= require ./kids/registrations/new

But it does not work. What I'm doing wrong. I'm checking the DOM (localhost:3000/kids/sign_up) but I never find line with this javascript file.

Thanks in advance for your help.


Adding the route

new_kid_registration GET /kids/sign_up(.:format) frontend/registrations#new

What I'm doing wrong.

Thanks.

Jean
  • 5,201
  • 11
  • 51
  • 87

2 Answers2

1

Try //= require kids/registrations/new or //= require kids/registrations/new.js

Bob
  • 2,081
  • 18
  • 25
0

I had faced similar problems while adding stylesheets to assets (Link to my question)

Here are few things you might wanna try:

  • As suggested by BOB add the require statements to application.js

  • I remember adding the list of files to application.rb as:

       config.assets.precompile += ['jquery.colorbox.js','colorbox.css', 'reportng.css', 'reportng.js'] 
    
  • Your JS file can be placed anywhere in lib/assets/javascripts, assets//assets/javascripts & vendor/assets/javascripts
  • Try using the <%= javascript_include_tag "your_js_file_name" %> in your view file
Community
  • 1
  • 1
Aks..
  • 1,343
  • 1
  • 20
  • 42