From: Zundra Daniel Date: 2008-04-24T23:56:24+09:00 Subject: Re: This can't be right ------=_Part_1791_10991312.1209048979570 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline property = content_properties.find_by_key('name') unless @name property ? @name = property.value : @name = "" @name Is one way On Thu, Apr 24, 2008 at 10:25 AM, Stefan Kroes wrote: > Hi all, > > I'm pretty new to Ruby and RoR but I'm trying to learn for a large > project. I wrote the following method in one of my models but it can't > be the right way to do this because ruby should be able to do it way > more concisely. Can you tell me of a better way? > > def name > if !@name > property = content_properties.find_by_key('name') > if property > @name = property.value > else > @name = "" > end > else > @name > end > end > > Thx in advance, > > with regards, > > Stefan Kroes > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_1791_10991312.1209048979570--