1

Here i am trying to include my custom js and css files in my rails application. i am a newbie to rails.. right now my application is linked to all the js and css files that i have in assets directory...

but i don't need them. i need to add only my js files.... how can i add it in to my rails application.... can i add it through layout file?

here is my layout file

<!DOCTYPE html>
<html>
<head>
  <title>Walden</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>  
  <%= csrf_meta_tags %>
</head>
<body>
<%= render 'shared/navbar' %>
<%= yield %>
</body>
</html>

right now it is linked to all css and js files like this.

<link data-turbolinks-track="true" href="/assets/user_details.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/application.css?body=1" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery_ujs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/turbolinks.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/affix.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/alert.js?body=1"></script>

example: i need to add only juery.js file and user_details.css file...how to add it?

1 Answer 1

1

Well, you have two basic choices:

Remove the extraneous files from your application.js and application.css.

or

<%= stylesheet_link_tag    'user_details', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'jquery', 'data-turbolinks-track' => true %>

http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/javascript_include_tag

http://apidock.com/rails/v4.2.1/ActionView/Helpers/AssetTagHelper/stylesheet_link_tag

Sign up to request clarification or add additional context in comments.

Comments

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.