Tidying up views

Hi,

I have the following code in one of my partials and it’s slightly
ridiculous so I was wondering whether anyone could give me some hints
as to the best way to tidy it up. The formatting performed here gets
performed in a number of places throughout the views.

I’m not sure whether to add methods to the model to deal with this
formatting or to use helpers or what.

I’d also be able to go the other way when it comes to the data fields,
i.e., be able to enter ‘1.8 M’ in a form field and have that converted
to bytes.

<%= top_talker_row.rank %> <%= h top_talker_row.ip_address %> <%= h top_talker_row.date_first_seen.to_s(:db) %> <%= h top_talker_row.data_date.date.strftime("%Y-%m-%d")%> <%= h number_to_time(top_talker_row.duration) %> <%= h top_talker_row.protocol.humanize %> <%= h number_with_delimiter(number_with_precision(top_talker_row.flows, 0)) %> <%= h number_with_delimiter(number_with_precision(top_talker_row.packets, 0)) %> <%= h number_to_human_size(top_talker_row.bytes) %> <%= h number_with_delimiter(number_with_precision(top_talker_row.packets_per_second, 0)) %> <%= h number_with_delimiter(number_with_precision(top_talker_row.bits_per_second, 0)) %> <%= h number_to_human_size(top_talker_row.bytes_per_packet) %> <%= h top_talker_row.network.name.humanize %> <%= h top_talker_row.top_talker_type.name.titlecase %> <%= link_to( image_tag('icons/application_form_magnify.png', :alt => 'Show'), top_talker_row, :title => 'Show' ) %>

Any help would be appreciated,
Thanks,
Toby

On Sep 17, 8:12 am, Toby C. [email protected] wrote:

Hi,

I’d also be able to go the other way when it comes to the data fields,
i.e., be able to enter ‘1.8 M’ in a form field and have that converted
to bytes.

that part’s easy:
http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Numeric/Bytes.html