I'm new to Rails and trying to figure out the correct way to handle
dynamic data in a partial. The partial in question will be used to
display a google ad. The html for this ad will differ based upon the
user (do they pay to not see ads, what the format/style of the ad will
look like needs to match the look and feel they have configured for
their profile, etc.).
I was looking to place an ad in a view as follows:
<%= render "shared/ad_banner", :ad_type => "120x90"%>
where the ad type basically specifies what size ad the ad_banner
partial needs to render. The different html for the ads are stored in
a database. My question is can/should the partial do a lookup to
figure out what ad html to render based upon the ad_type passed in
(along with information about the currently logged in user)? Or should
the actual lookup occur in the controller and the html be passed into
the partial? My first thought was it would be cleaner if I had the
partial do the lookup since the controller would not have to have any
knowledge about what size ad needs to be rendered, this information
was basically embedded in the view.
However, when trying to figure out how to make the partial do the
lookup I started wondering if this was bad form based upon the lack of
examples I saw for this type of approach (all the examples seemed to
be passing the data in).
Any guidance would greatly be appreciated.