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.

Reply
Join the discussion
Create an account Log in

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

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

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