Repeated code in browser stats app needs common object

Complete.
Although there was already common code in /layouts for each controller and thus shared code between 4 files (per controller), it was still being repeated from controller to controller, so just wasn't dry enough. Initially it was hard to make this code an object due to some hard coded references to table names, etc. but as these were also available as controller names, method names, etc. was able to 'reference' everything with code such as:

<title><%= controller_name.capitalize %>:<%= controller.action_name %></title>

and

<h1>Table: <%= controller_name %></h1> 


Then (after a fair bit of testing!) I was able to rename and finally delete all the other files in /layouts and reduce the number of files to maintain from 12 to just 1 :yes:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s