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 8394505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:04:46+00:00 2026-06-09T20:04:46+00:00

I would like to make a Rails app that lets users enter data and

  • 0

I would like to make a Rails app that lets users enter data and then allow them to change the page’s theme. This way their data could be styled differently based on the theme they choose. How would I go about doing this?

  1. Change stylesheet?
  2. Two separate views with different classes/elements?
  3. Dynamically just change classes/ids/selectors?
  4. ?

Thanks

  • 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-09T20:04:48+00:00Added an answer on June 9, 2026 at 8:04 pm

    The easiest way to theme a site is to simply link to a different stylesheet. You can do this dynamically using something like:

    # in app/views/layouts/application.html.erb
    <%= stylesheet_link_tag :application %>
    <%= stylesheet_link_tag #{current_theme} %>
    
    # in app/helpers/application_helper
    def current_theme
      # You'll have to implement the logic for a user choosing a theme
      # and how to record that in the model.
      # Also, come up with a better name for your default theme, like 'twentyeleven' ;)
      current_user.theme || 'default'
    end
    

    Then you can have a couple manifests for themes. For example, your assets directory can look something like this:

    • app/assets/stylesheets
      • application.css
      • buttons.css
      • theme1/
        • index.css
        • buttons.css
      • theme2/
        • index.css
        • buttons.css

    This will get you started with pure css theming. At some point you’ll probably want to also them javascript and html layouts. When you start finding the need to do something like this in your html:

    <% if current_theme == 'theme1' %>
      <li>...
    <% elsif current_theme == 'theme2' %>
      <b>...
    <% end %>
    

    then it’s time to implement a more robust theming framework:

    • namespace your html templates by theme (e.g. app/views/themes/theme1/users/index.html.erb) and render the themed version instead of the default
    • namespace just the partials by template (e.g. app/views/themes/theme1/users/_form.html.erb) and add a helper method like render_themed_partial
    • similar to the above approaches, but when the themes get very large, you should consider putting them into their own gems as rails engines

    Note: This is all for static themes. For dynamic themes (e.g. where an admin can login and edit the stylesheets or html), you’ll have to store theming information in the database. Depending on your architecture, you may be able to provide a set of static themes, and then another theme that dynamically grabs styling data from the database. At that point, you’re developing a CMS, however, so it’s outside the scope of this answer 🙂

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

Sidebar

Related Questions

Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make my app freeware, but if a user is willing
I would like to make a function that takes in a list of integers
I have some data that I want to store somewhere in my Rails app
I am building an iPhone app where I would like authenticate with a rails
To make a long explanation short, suffice it to say that my Rails app
I am trying to build a Rails app that uses the YouTube data API
I would like for a user within my ruby on rails app to be
I have two local rails apps that I would like to talk to each
I would like to define a custom logger for my Rails 3 app, in

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.