2

I have seen many answers to similar posts on Stackoverflow and I tried implementing it but it is not working. I have done the following things

1) Removed //= require_tree . from assets/javascripts/application.js

2) Added //= require users in the assets/javascripts/application.js (where users.js is my javascript file in the same folder as the application.js resides)

In my new.html.erb I have included the following line

   <%= javascript_include_tag "users" %>

3) users.js contains simple javascript code like "alert(6)"

When I make request to users/new thru localhost I do not get any alert although I can see my users.js included in the html but there is no code in that. Can anyone please help me on this??

1 Answer 1

1

Since you have included users.js inside application.js, you should add application.js to the page

In new.html.erb, replace users with application

Remove this line

<%= javascript_include_tag "users" %> 

And add this line

<%= javascript_include_tag "application" %>
Sign up to request clarification or add additional context in comments.

2 Comments

I said I have included users.js in the same folder as in application.js. I am not sure what do you mean by including user.js inside application.js?
It is not working. Also I would like to mention that the above line include application is already there in application.html.erb under layouts folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.