# DRY conflict with "Updated at" "Created at" "Deleted at" in

**URL:** <https://www.ruby-forum.com/t/dry-conflict-with-updated-at-created-at-deleted-at-in/98218>\
**Category:** Rails\
**Created:** [January 28, 2006, 10:45am UTC](https://www.ruby-forum.com/t/dry-conflict-with-updated-at-created-at-deleted-at-in/98218 "2006-01-28T10:45:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerardjp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gerardjp](https://www.ruby-forum.com/u/gerardjp)\
**Post date:** [January 28, 2006, 10:45am UTC](https://www.ruby-forum.com/t/dry-conflict-with-updated-at-created-at-deleted-at-in/98218/1 "2006-01-28T10:45:43Z")

</div>

Hi all,

Are there any helpers or so for listview routines that suppres the three  
above  
mentioned columns? I’m currently exploring something like the code  
below. But  
it feels like I’m doing Rails’ work.

# just for test purposes

\<% for col in Product.columns.map %\> \<%= col.name %\> - \<%= col.type %\>  
\<% end %\>

Skip if … well, you know …  
\<% for column in Product.columns.map %\>  
\<% next if column.name == ‘id’ %\>  
\<% next if column.name ~= ‘\_id’ %\>  
\<% next if column.name == ‘created\_at’ %\>  
\<% next if column.name == ‘deleted\_at’ %\>  
\<% next if column.name == ‘contact\_id’ %\>

Thanx!

Gerard.

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!

---

<div class="post-metadata">

**Author:** ![gerardjp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gerardjp](https://www.ruby-forum.com/u/gerardjp)\
**Post date:** [January 28, 2006, 11:00am UTC](https://www.ruby-forum.com/t/dry-conflict-with-updated-at-created-at-deleted-at-in/98218/2 "2006-01-28T11:00:49Z")

</div>

Rather than interacting with the Product model in your view, you  
should be selecting the columns to display from the controller:

def list  
hidden\_columns = [“created\_at”, “updated\_at”, …]  
@columns = Product.content\_columns.delete\_if { |c|  
hidden\_columns.include?(c.name) }  
end

… and then iterate over @columns rather than Product.columns in your  
view.

- james

---

<div class="post-metadata">

**Author:** ![gerardjp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gerardjp](https://www.ruby-forum.com/u/gerardjp)\
**Post date:** [January 28, 2006, 11:31am UTC](https://www.ruby-forum.com/t/dry-conflict-with-updated-at-created-at-deleted-at-in/98218/3 "2006-01-28T11:31:04Z")

</div>

James,

Brilliant tip, that way I’m also not avoiding the regular data access  
using  
the content\_column instead of the columns(.map) like now.

I realise that I’m still doing stuff in views that can(read: must) be  
done in  
models. This helps, Thanx a lot!

Gerard.

On Saturday 28 January 2006 10:59, James A. tried to type something  
like:

> > \<% next if column.name == 'deleted\_at' %\> Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..."
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!

---

<div class="post-metadata">

**Author:** ![gerardjp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gerardjp](https://www.ruby-forum.com/u/gerardjp)\
**Post date:** [January 28, 2006, 12:01pm UTC](https://www.ruby-forum.com/t/dry-conflict-with-updated-at-created-at-deleted-at-in/98218/4 "2006-01-28T12:01:10Z")

</div>

James,

Ik misspoke myself in the pevious mail. Where I said to use it in the  
model  
(still a bit of a newbie I guess). I works like a charm in the  
controller. So  
the next Q (as you probably guess):

Shouldn’t stuff like this belong in the model since it’s alteration of  
data  
(imho) not on an application flow kind of level?

Tnx n Grtz

Gerard

On Saturday 28 January 2006 10:59, James A. tried to type something  
like:

> hidden\_columns = [“created\_at”, “updated\_at”, …]  
> @columns = Product.content\_columns.delete\_if { |c|  
> hidden\_columns.include?(c.name) }

–  
“Who saysif it doesn’t do anything? It was made with our new  
RubyOnRails process …”

My $Grtz =~ Gerard;  
~  
:wq!
