Sharing code in views

You can use the layout file do that. Look at the following railscasts. it will clarify how layout works (it is a 7 min video)

http://railscasts.com/episodes/7

Emmanuel