Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:48:01+00:00 2026-06-07T13:48:01+00:00

In a Rails 3.1 app, one controller needs to have all its views compile

  • 0

In a Rails 3.1 app, one controller needs to have all its views compile whatever Sass stylesheets they might need per request using a set of custom variables. Ideally, the compilation must happen via the asset pipeline so that content-based asset names (ones that include an MD5 hash of the content) are generated. It is important for the solution to use pure Sass capabilities as opposed to resorting to, for example, ERB processing of Sass stylesheets.

From the research I’ve done here and elsewhere, the following seems like a possible approach:

  1. Set up variable access

    • Create some type of variable accessor bridge using custom Sass functions, e.g., as described by Konstantin Haase here (gist). This seems pretty easy to do.

    • Configure all variable access via a Sass partial, e.g., in _base.sass which is the Compass way. The partial can use the custom functions defined above. Also easy.

  2. Capture all asset references

    • Decorate the asset_path method of the view object. I have this working well.

    • Resolve references using a custom subclass of Sprockets::Environment. This is also working well.

  3. Force asset recompilation, regardless of file modification times

    • I have not found a good solution for this yet.

    • I’ve seen examples of kicking off Sass processing manually by instantiating a new Sass::Engine and passing custom data that will be available in Sass::Script::Functions::EvaluationContext. The problem with this approach is that I’d have to manage file naming and paths myself and I’d always run the risk of possible deviation from what Sprockets does.

    • I wasn’t able to find any examples of forcing Sprockets processing on a per-request basis, regardless of file mod times, that also allows for custom variable passing.

I’d appreciate comments on the general approach as well as any specific pointers/suggestions on how to best handle (3).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:48:03+00:00Added an answer on June 7, 2026 at 1:48 pm

    Sim.

    It is possible. Look here SASS: Set variable at compile time

    I wrote a solution to address it, I’ll post soon and push it here, in case you or someone else still need it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Rails 3 app: no models, one view and one controller
I am creating a rails app and have used this code in one of
In my Rails app, I have a model Page which represents one HTML article
I have a little one-liner in my Rails app that returns a range of
I have a rails 3.2 app that uses 2 databases. One database is the
Here after called the controller.rb, one file(chart.png) will save in my rails app folder,
I'm using the Sorcery library in a rails app. One of its modules is
How does one approach building the mobile app version of one's Rails app, with
Can I use MongoDB and a PostgreSQL in one rails app? Specifically I will
My model name in one of rails app is OrganizationUser and is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.