Take the 2-minute tour ×

I want to create a widget-like entity for my Rails app. For example, I'd like to be able to render a list of products marked as featured and have it work in any view file.

My first thought was to try to do this using a partial. Is this the best way? Will I be able to achieve my overall goal of having a widget I can inject anywhere? What's the best way to implement this?

share|improve this question
add comment

1 Answer

Markup that is shared across many view files should be placed in a shared partial.

In this case, your partial will depend on having a collection of products available. You will need to query this collection in each controller action that corresponds to a page containing the widget. This sounds like a good way to do it to me.

share|improve this answer
add comment

Your Answer


