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... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Paul Lynch 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/17/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Paul Lynch 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? >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Max Muermann wrote:> On 10/17/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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, > MaxEvery 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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/19/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Max Muermann wrote: > > On 10/17/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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! >I''d put it in the model. It is clearly a business-logic-type task. Max --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---