Forum: Ruby on Rails how to trim my view? using different models? simple im sure.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
mixplate (Guest)
on 2007-03-22 15:44
hi,
i have a view page that display a little information about my models.
basically i have 4 different models and all four have some fields in
common like timestamp, description, and category. right now i have 4
different view files that do the same..

viewtype1.rhtml

for something in @myvariableType1
   something.description
   etc...
   something.Type1.picture
end

viewtype2.rhtml

for something in @myvariableType2
   something.description
   etc...
end

etc...



is there a way to not have 4 different view files? cant i use class to
name or something?

thanks
Dave C. (Guest)
on 2007-03-22 16:16
mixplate wrote:
> is there a way to not have 4 different view files? cant i use class to
> name or something?

you can separate all of your common code into partials.
http://api.rubyonrails.com/classes/ActionView/Partials.html
This topic is locked and can not be replied to.