0

Is there some way, any way to limit access to the rails asset pipeline for users browsing your app?

I want to limit access to certain CSS only when a user is logged in, rails should block access to it otherwise.

Could not find anything relating this Is it possible?

Rubytastic
  • 15,001
  • 18
  • 87
  • 175

1 Answers1

1

Personally i will compile the assets i dont want public separately in my production.rb file

example

config.assets.precompile += %w(locked.css ) 

then in my application layout i will add a yield to the head tag

example

<%= yield(:head)%>

then i can now perform my check to know if there is a current_user or not

example

<% if current_user %>
  <%= provide(:head) do %>
     <% stylesheet_link_tag "locked" %>
  <% end %>
<% end %>

This might be kind of lame but it gets the job done.

Uchenna
  • 4,059
  • 6
  • 40
  • 73
  • Yes but I want to disable /assets/whatever.css also, so they should not be able to get the contents at all. Guess this requires serving the assets true a controller making everything extreme complicated – Rubytastic Jan 31 '13 at 15:21
  • grant yours as correct answer, not a full solution to my problem but its correct. – Rubytastic Feb 01 '13 at 09:49