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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:56:45+00:00 2026-05-24T18:56:45+00:00

Let’s say I have a Partner model which represents an affiliate partner in an

  • 0

Let’s say I have a Partner model which represents an affiliate partner in an ad network. Each partner is associated with a commission which can be fixed (absolute currency) or variable (percentage). The partners table models this with columns commission_type, commission_fixed and commission_variable. This is a simplification, there are actually 7 commission types, so single-table inheritance or multiple models would require lots of extra code.

In my view, I want to display the commission, like this:

<div class="partner_commission"><%= partner.commission %></div>

(using model method)

or

<div class="partner_commission"><%= commission(partner) %></div>

(using helper method)

Now, one important aspect to note is that the entire application is multilingual, so every string in the view has to be translated with the I18n.translate / I18n.t helper. The translation contains more than just number / currency format, so custom translations for the commission string are needed (never mind why).

The method looks like this (simplified model version):

def commission
  case self.commission_type
  when 'commission_fixed'
    t(:commission_fixed, :value => self.commission_fixed)
  when 'commission_variable'
    t(:commission_variable, :value => self.commission_variable)
  end
end

The question is: Where should I implement the commission method to be in compliance with MVC philosophy, best practices, etc.?

The reason for putting it in the helper would be that it only concerns the presentation of the commission data in the view, not the data itself. On the other hand, a helper method has to be implemented which only concerns a single model, but is used across many views, which feels wrong.

The reason for putting it in the model would be that the commission string can be seen as a derived attribute and hence should be defined in the model. On the other hand, I have to manually include the i18n view helpers to use I18n.translate in the model, which feels strange.

What do you think?

  • 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-05-24T18:56:46+00:00Added an answer on May 24, 2026 at 6:56 pm

    I would say it should go in the model. Models are supposed to control your data, and that is exactly what you want your commission method to be doing. It is perfectly OK in MVC to use model methods to combine/modify data in order to return it in a nice form.

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

Sidebar

Related Questions

Let's say I have a dataset, which can be neatly classified using weka's J48
Let's say you have a class called Customer, which contains the following fields: UserName
Let's suppose I have a Discussion model, and that a discussion can be tagged.
Let's say R is a mxn random matrix. How can generate R with each
Let's say I have the following models class Photo(models.Model): tags = models.ManyToManyField(Tag) class Tag(models.Model):
Let's say I'm building a data access layer for an application. Typically I have
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I have a drive such as C:\ , and I want to
Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and

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.