Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic css - wrong content type
    primarykey
    data
    text
    <p>I need to add customizable interface for each user in my app. So after some googling i decided to generate css, cache it for every user and link it in views. I found <a href="https://stackoverflow.com/questions/4729282/best-way-to-handle-dynamic-css-in-a-rails-app">good post</a> and used it as example.</p> <p>So there is pieces of resulting code from my app:</p> <p>In controller <strong>shedule_themes_controller.rb</strong>:</p> <pre><code>... def get_css respond_to do |format| format.css { render :text =&gt; "body {\n background-color: blue; \n}", :content_type =&gt; Mime::CSS } end end </code></pre> <p>In <strong>layout</strong>:</p> <pre><code>... &lt;%= stylesheet_link_tag "application" %&gt; &lt;link href="&lt;%= get_css_path %&gt;" media="screen" rel="stylesheet" type="text/css" /&gt; </code></pre> <hr> <p>But when i start application, the css doesnt't load. It comes 406 Not Acceptable Error. And response headers are:</p> <pre><code>Cache-Control:no-cache, private Connection:Keep-Alive Content-Length:1 Content-Type:text/html; charset=utf-8 </code></pre> <p>So as you see, response has content/type <strong>text/html</strong> so 406 error is.</p> <p>Can anyone explain me, why controller response with text/html if request content-type is text/css ?</p> <p>P.S. I tried to manually send request to localhost:3000/get_css using Google Chrome DEV HTTP CLIENT. I set up Content-Type: text/css and server responded with right css and content-type:</p> <pre><code>body { background-color: blue; } </code></pre> <p>So probably i made some mistakes in linking dynamic css in my layout?</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload