All threads / Rails 6: How do you associate specific stylesheet and external js plugin to a layout

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Rails 6: How do you associate specific stylesheet and external js plugin to a layout

Joan Gabun asked in General

I am working on Ruby on Rails 6. My application has a controller that uses a different layout called "special":

class BoxController < ApplicationController
  layout "special"
  ...
end

So I've created a new layouts/special.html.erb:

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <%= stylesheet_link_tag "special" %>
  <%= javascript_link_tag "special" %>
  <%= csrf_meta_tags %>
</head>
<body>
 <%= yield %>
</body>
</html>

I then placed my 3rd party css and plugin under vendor->stylesheets and javascript folder:

stylesheets
  -monnom.css
  -mintymon.css

javascript
  -monnom.js
  -mintymon.js

I tried this but did not read my css and js.

What am I doing wrong? What am I missing in order for this work?

Can anyone guide me step by step? a super beginner here.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.