Dynamic Custom Dashboard Widgets


I need to display some data to users and think dashboard custom widget may be the way to go. I’ve seem the documentation that suggest creating .html or .html.erb documents here: Customizations — Open OnDemand 3.1.0 documentation .

I’m looking to make the widget dynamic as it would need to display different information based on the user logged in. This involves identifying the user in the session, getting the user data from a certain log file, doing some calculations and finally populating the .html or .html.erb with the content to display on the widget. I wanna go with dashboard widget as I’d like the user to see the information right-away once logged-in and they shouldn’t have to click any buttons or links etc. Is this something possible in widgets? If yes, can you please suggest how?

If not, can you share what options are there to achieve this? Passenger Apps maybe?

Really appreciate the work you folks are doing, Thanks,

Sure this can all be done by using the partials as the docs explain. You would have to do some work to get all the relevant data called into the partial, but it is possible.

Have you had much experience with something like ERB and partials? I can try to mock up an example of how to do some of this if not.

Hi, thank you for your response and help here. Unfortunately, newbie here in terms or erb and haven’t come across partials in the documentation so not sure what those are in the first place. So, would really appreciate if you could point me to the right direction or mock up an example.


No problem. A partial in Ruby on Rails ERB is a reusable snippet of code that you can use within your view files. It helps to keep your code organized and avoid repetition mostly.

So what you need to do is add a custom widget:

If you are using the sandbox to do this work, you can just land that partial in your dashboard/app/views/widgets to then reference from the config.

Inside that partial you can use ERB to make calls to the backend and retrieve information which you may need. This is what will give you that bridge between the data you need and presenting it to the user.

Ok, so here’s a basic example to show you some plumbing. I’m going to work out of my sandbox in this example, so I need to land my widget in $HOME/ondemand/dev/dashboard/app/views/widgets/_custom.html.erb with a basic smoke test:

<div class="container">

Then ensure I’m using a configuration file out of my developer environment by setting my environment variables in my .env.local at the root of my dashboard app:


I make that ondemand.d directory in my dashboard sandbox and add a ondemand.yml with the following:

    - columns:
      - width: 8
        - custom

Now when I launch my dashboard, I can see a small bit of text from the widget.

At this point it’s a matter of now putting more data that you need into that widget, and this is where the ERB comes in. You’ll have to read more on it yourself but the basic idea if it will render some text and send it back to be inserted into the html. Now, if you use a <%= %> tag the text is literally inserted and there, but if you use <%- -%> tags the code in between will compute, and the variables will be available, but none of that will write out.

It sounds harder than it is once you’ve spent 10 minutes with it. The point is you can do things like what you see in this app, where we compute or retrieve a bunch of data at the head of the file, to then be used throughout the rest. This is just an example of how to use ERB btw, not saying this file is what you would need to touch:

That’s a lot and i’m sure you’ll have more questions. Sorry for the wall of text but I hope it helps.

Hi @travert,

That was a really good explanation and I was able to start experimenting quite quickly. I could also get the username for logged in user with OodSupport::User.new. Thank you for that.

For now, I only have just one question. I’m working on OOD in a test deployment so I’ve deployed the widget directly in /etc/ood/config/apps/dashboard/views/widgets/. I need to interact with a sqlite3 database and get table values. I’m trying to import ruby gem sqlite3 like this:
<% require 'sqlite3' %>

I get the following error in the dashboard:

#<LoadError: cannot load such file – sqlite3>

This error is followed by a lengthy stack trace (which I don’t think is helpful but let me know and I’ll paste that here). I’m assuming the error is because sqlite3 gem doesn’t exist and I’ve tried installing it with gem install sqlite3.

Unfortunately, the error is persistent, leading me to wonder if there’s a custom path for gems in OOD rather than /usr/share/gems and /usr/local/share/gems? Please let me know what I’m missing here.


For this issue you are going to have to go a bit deeper. The problem is the required sqlite3 gem is not installed.

Inside the dashboard app there is a ~ondemand/dev/dashboard/Gemfile, and you will need to play with adding an entry like:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '7.0.8'
gem 'sqlite3' # add your gem here.

Now, you will have to rebuild your dev dashboard when you do this as it needs to pull that gem into the project for use. To do so, issue the following command to ensure you are building out of the app directory:

bundle config set --local path 'vendor/bundle'

Then from the root of the dashboard app you just run:


And this should handle your build to pull that new gem in and be ready to use.

After the build is done, if you use the gem anywhere in the code and launch your development dashbaord you should be all set to go.

After the gem is actually on the system, you should be able to use require 'sqlite3 in your code.

Hi @travert,

Thank you for these steps as they worked beautifully. That being said, it appears the rebuilding has caused a strange error. I cannot see most of the icons anymore.

Icons for Interactive Apps are still there so only the out-of-box icons are affected. What could be causing this? I’m not sure what other information I need to share about this issue but please let me know.


Hi @travert,

Some more information about the icons. It looks like they are part of the font-family “font awesome” and that font fails to load. See the browser console errors below:

downloadable font: download failed (font-family: “Font Awesome 5 Free” style:normal weight:900 stretch:100 src index:1): status=2147746065 source: http://test.com/pun/dev/dashboard/assets/fa-solid-900-9834b82ad26e2a37583d22676a12dd2eb0fe7c80356a2114d0db1aa8b3899537.woff2
downloadable font: download failed (font-family: “Font Awesome 5 Free” style:normal weight:900 stretch:100 src index:2): status=2147746065 source: http://test.com/pun/dev/dashboard/assets/fa-solid-900-3f6d3488cf65374f6f676c315340b0ac2be832bd55240c809448e36ef9b96326.woff
downloadable font: download failed (font-family: “Font Awesome 5 Free” style:normal weight:900 stretch:100 src index:3): status=2147746065 source: http://test.com/pun/dev/dashboard/assets/fa-solid-900-af6397503fcefbd613976c21ad5c1e37298c18bbe07d096db03ccd3af6e05ba8.ttf
downloadable font: no supported format found (font-family: “Font Awesome 5 Free” style:normal weight:900 stretch:100 src index:5) source: (end of source list)

Hope this hints towards what’s the issue.

So sorry for not noticing your previous post about the icons!

Is there anything that would prevent the fonts from downloading? I’m just going off the logs here because this is a new error to me.

no worries. the test system has internet access and I don’t see a reason why the download would fail. can you provide any details about these font downloads so I can look into the particular directories or maybe try downloading them manually to see if it works?

I take it you edited the production Gemfile? I.e., the one located in /var/www/ood/apps? When you rebuilt, you rebuilt for the development environment, not the production environment. That’s why the assets are missing - you see the URL is /pun/dev instead of /pun/sys.

I’d suggest re-installing the package to wipe these modifications. Any modifications you make here aren’t permanent anyhow - an update or the next version would have wiped them out anyway.

There is, but when you gem install you should do so as root. OnDemand should be able to find gems in these system locations.

Basically - you want to add the gem to the system gem location - not edit our Gemfile or add to our gem locations, because again, updates to OnDemand are just going to overwrite these - so it’s not something that’ll persist.

There’s also likely a package (deb or rpm) for that gem, so you should try to dnf search for it or similar.

Hi @jeff.ohrstrom,

Thank you for the detailed response. I’m a little confused here. I edited the Gemfile in /var/www/ood/apps so shouldn’t the rebuilt be for production? Anyways, I understand these changes won’t persist across updates so I’m going to avoid making these changes.

On installing sqlite3 gem using dnf, I’m getting into the following error:

Problem: package rubygem-sqlite3-1.4.2-2.el8.x86_64 from epel requires libruby.so.2.5()(64bit), but none of the providers can be installed

Looks like the package has a dependency on libruby which is provided by ruby-libs-2.5.9 and therefore cannot be downloaded since ruby-libs-2.5.9 is not supported by ruby-3. I’ve reached a dead end in trying to resolve this so I’m focusing on using gem to install sqlite3.

On installing sqlite3 with gem, it has been installed using root account but that hasn’t made on-demand pick it up for some reason.

I’d appreciate if you could suggest something that’d allow ood to pick up on sqlite3 gem.


I see you’re on EL8 - what’s the Linux flavor you’re on - I can try to play around to see what’s what.

You could have rebuilt for production but I’m not sure what other errors you may have ran into. Maybe none, maybe a whole lot. I just don’t know what other unexpected behavior would pop up if you continued to edit & recompile these files, and it seems to me like there should be an easier/simpler way out.

@jeff.ohrstrom I’m using Rocky Linux 8.9. I didn’t see any other errors while rebuilding. That being said, I’m simply not going to mess with production files as it’s not going to persist across reboots so no need for troubleshooting there. Just getting sqlite3 gem recognized within the widget should do the trick.

OK - this is a little wonky (may very!) but I got this to work. I’ll file a ticket upstream to see what we can do to support this in the future (I thought we would already, but I guess not…)

  require 'sqlite3'

@jeff.ohrstrom that worked just fine, thanks a lot