I have the following HTML table code:
<table>
<tr>
<th>Time</th>
<th>Source</th>
<th class="hide-on-phones">Destination</th>
<th>Duration</th>
</tr>
<tr>
<td>11 Mar. 2012 - 16:37</td>
<td>0778593789</td>
<td class="hide-on-phones">08456783850</td>
<td>00:03:10</td>
</tr>
</table>
The content is populated from the Rails application database, the destination field is called destination in the database.
On the Rails side of things, the content is pulled from my Calls model which is populated by a rake task. The rake task screen scrapes our providers website for the call log.
Ideally, I would like to replace the destination content with a company name (without making database relationships etc). It’s only for this page and the Rails application is tiny and simple.
I imagine either a CSS rule to replace the number with an image or a Rails statement to filter the number and if it matches a set value then replace with a phrase (company name).
Is there an easy way to do this that I have overlooked?
UPDATE
When using the following suggested code I get an error. I don’t think the when statement can start with a zero.
module CallsHelper
def format_destination(destination_number)
case destination_number
when 08456742850
image_tag "number_1234.jpg"
when 5678
image_tag "number_5678.jpg"
else
image_tag "default_number.jpg"
end
end
end
Why not create a helper method to convert your destination to the value you want to display?
I’m assuming that you have a distinct set of destinations that wont change, which will allow you to hard-code them in your application without needing to store them in the DB for modification later through the application?
Something like this?