Design-Problem

hi @ all

I’ve a design problem in my ror-project. I’m using a simple
rails-application to manage some data. I would like to present
percentage-numbers in different views. But I want to save the
percentages as a decimal number in the database.

When I save or read a record, is that the job for the controller or the
model, to present me the percentage number (not the saved decimal
number)? Why?

Thanks for the solutions…

On 17 Oct 2006, at 13:08, M. R. wrote:

I’ve a design problem in my ror-project. I’m using a simple
rails-application to manage some data. I would like to present
percentage-numbers in different views. But I want to save the
percentages as a decimal number in the database.

When I save or read a record, is that the job for the controller or
the
model, to present me the percentage number (not the saved decimal
number)? Why?

Neither, it’s a view responbsibility, ideally using a helper
function. Why? Because it’s about formatting and presentation.

number_to_percentage() will do the job nicely.

Paul

Paul L. wrote:

On 17 Oct 2006, at 13:08, M. R. wrote:

Neither, it’s a view responbsibility, ideally using a helper
function. Why? Because it’s about formatting and presentation.

number_to_percentage() will do the job nicely.

But when I use the number for a calculation before I present it on a
view? Is it a controller-task?

On 10/17/06, M. R. [email protected] wrote:

But when I use the number for a calculation before I present it on a
view? Is it a controller-task?

Probably a model task. Depends on what your calculating an for what
purpose. For example calculating the total value of an order across
all the order line items is certainly a model responsibility. Adding
up a whole bunch of numbers that the user has ticked on a form would
be more in the controller’s domain.

Cheers,
Max

On 10/19/06, M. R. [email protected] wrote:

all the order line items is certainly a model responsibility. Adding

Is it a controller or model task?

The newbie need help. Thanks for your solution!

I’d put it in the model. It is clearly a business-logic-type task.

Max

Max M. wrote:

On 10/17/06, M. R. [email protected] wrote:

But when I use the number for a calculation before I present it on a
view? Is it a controller-task?

Probably a model task. Depends on what your calculating an for what
purpose. For example calculating the total value of an order across
all the order line items is certainly a model responsibility. Adding
up a whole bunch of numbers that the user has ticked on a form would
be more in the controller’s domain.

Cheers,
Max

Every day, the user ticked on a form some percentage changes in. With
this number and some saved records from the database, I calculate a
value. This calculated value and the percentage change are saved in the
database.

Is it a controller or model task?

The newbie need help. Thanks for your solution!