# Two Noob Questions

**URL:** <https://www.ruby-forum.com/t/two-noob-questions/146952>\
**Category:** Rails\
**Created:** [August 27, 2008, 1:52am UTC](https://www.ruby-forum.com/t/two-noob-questions/146952 "2008-08-27T01:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trope](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/71c47a/32.png) [@trope](https://www.ruby-forum.com/u/trope)\
**Post date:** [August 27, 2008, 1:52am UTC](https://www.ruby-forum.com/t/two-noob-questions/146952/1 "2008-08-27T01:52:43Z")

</div>

I am building my first application, and have a couple of quick  
questions. Hopefully someone can point me in the right direction.

1. When I created my model , I noticed a field named “created\_at” ,  
which comes in handy. But when I retrieve the value , it comes back  
very long and un-user friendly. How do I return this date as: Jun 23  
08 , or March 21, 2008 , etc?

2. In my layout , I have some simple CSS which formats some tabs  
( li’s ). If we are on a certain page , I would add “class = current”  
to make the tab background a different color. How do I differentiate  
which page I am on , so I can add the class current to the proper  
page?

Thanks! Glad to be on board.

JT

---

<div class="post-metadata">

**Author:** ![trope](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/71c47a/32.png) [@trope](https://www.ruby-forum.com/u/trope)\
**Post date:** [August 27, 2008, 2:18am UTC](https://www.ruby-forum.com/t/two-noob-questions/146952/2 "2008-08-27T02:18:28Z")

</div>

JT,

1. Look through strftime at  
[class Time - RDoc Documentation](http://ruby-doc.org/core/classes/Time.html#M000297)  
e.g: created\_at.strfime(‘%B %d’) == ‘January 01’

2. controller.controller\_name and controller.action\_name give you the  
current controller and action in a view.

Here’s some ideas on tab helpers:  
[http://www.therailsway.com/2007/6/4/free-for-all-tab-helper](http://www.therailsway.com/2007/6/4/free-for-all-tab-helper)  
[http://www.therailsway.com/2007/6/28/free-for-all-tab-helper-summary](http://www.therailsway.com/2007/6/28/free-for-all-tab-helper-summary)

---

<div class="post-metadata">

**Author:** ![trope](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/71c47a/32.png) [@trope](https://www.ruby-forum.com/u/trope)\
**Post date:** [August 27, 2008, 2:27am UTC](https://www.ruby-forum.com/t/two-noob-questions/146952/3 "2008-08-27T02:27:14Z")

</div>

There’s also params[:controller] and params[:action] that do the same  
thing as controller.controller\_name and controller.action\_name  
respectively.

---

<div class="post-metadata">

**Author:** ![trope](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/71c47a/32.png) [@trope](https://www.ruby-forum.com/u/trope)\
**Post date:** [August 27, 2008, 2:22am UTC](https://www.ruby-forum.com/t/two-noob-questions/146952/4 "2008-08-27T02:22:33Z")

</div>

On Tue, Aug 26, 2008 at 7:52 PM, trope [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am building my first application, and have a couple of quick  
> questions. Hopefully someone can point me in the right direction.
> 
> 1. When I created my model , I noticed a field named “created\_at” ,  
> which comes in handy. But when I retrieve the value , it comes back  
> very long and un-user friendly. How do I return this date as: Jun 23  
> 08 , or March 21, 2008 , etc?

strftime is your answer

[http://ruby-doc.org/core/classes/Time.html#M000297](http://ruby-doc.org/core/classes/Time.html#M000297)

Make sure to set your time zone in environment.rb

> 1. In my layout , I have some simple CSS which formats some tabs  
> ( li’s ). If we are on a certain page , I would add “class = current”  
> to make the tab background a different color. How do I differentiate  
> which page I am on , so I can add the class current to the proper  
> page?

In your controller set an instance variable such as:

@css\_class = “class = current”

Use it in your page as:

\<%= @css\_class %\>
