this one really has me stumped... <%= user.in_out == "In" ? {image_tag url_for_file_column("personnel", "image", "thumb")} if user.image : user.in_out %> What I am wanting to do... if user.in_out == "In", load their thumbnail if it exists, load public/images/in.jpg if not, or else load public/images/out.jpg Can someone help with the construction of this? Craig
Perhaps just write a utility method in the user model, or in a helper for this. For instance, you could add these methods to your user class (untested): def get_thumbnail if in? self.image.nil? ? ''in.jpg'' : self.image else ''out.jpg'' end end def in? self.in_out == ''In'' end Then in your view you could just say: <%= image_tag(user.get_thumbnail()) %> Tom On 7/2/06, Craig White <craigwhite@azapple.com> wrote:> this one really has me stumped... > > <%= user.in_out == "In" ? {image_tag url_for_file_column("personnel", > "image", "thumb")} if user.image : user.in_out %> > > What I am wanting to do... > > if user.in_out == "In", load their thumbnail if it exists, load > public/images/in.jpg if not, or else load public/images/out.jpg > > Can someone help with the construction of this? > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tom Davies http://atomgiant.com http://gifthat.com
Hi Craig, Craig White wrote:> > What I am wanting to do... > > if user.in_out == "In", load their thumbnail if it exists, load > public/images/in.jpg if not, or else load public/images/out.jpgI''ve not used image_tag yet so I''ll not guess about the syntax for that, but WRT the other part... <% if @user.in_out == ''In'' %> load public/images/in.jpg <% else %> load public/images/out.jpg <% end %> Notice that you''ll need to make the ''user'' variable an instance variable for the view to have access to it. hth, Bill
On Sun, 2006-07-02 at 11:15 -0500, Bill Walton wrote:> Hi Craig, > > Craig White wrote: > > > > What I am wanting to do... > > > > if user.in_out == "In", load their thumbnail if it exists, load > > public/images/in.jpg if not, or else load public/images/out.jpg > > I''ve not used image_tag yet so I''ll not guess about the syntax for that, but > WRT the other part... > > <% if @user.in_out == ''In'' %> > load public/images/in.jpg > <% else %> > load public/images/out.jpg > <% end %> > > Notice that you''ll need to make the ''user'' variable an instance variable for > the view to have access to it.--- thanks - the logic methology inside the view code was what I needed to understand. I got it now Thanks Tom too. Craig