Rahul, Exceptions handling in Ruby is done the following way.
begin <some code> rescue <exception> <some exception handling code> end When a partial template is missing Rails will throw an exception. As a result, to catch a missing partial template exception (ActionView::MissingTemplate) you need to rescue that exception by name. In ERB the syntax for this is <% rescue ActionView::MissingTemplate %>. Anthony Crumley http://commonthread.com On Sat, Apr 10, 2010 at 4:05 AM, Rahul Mehta <[email protected]>wrote: > Hi Anthony, > > <% begin %> > <%= render :partial => 'custom' %> > <% rescue ActionView::MissingTemplate %> > Default > <% end %> > > why this begin and end are used > what is mean by > <% rescue ActionView::MissingTemplate %> > > can you tell me > > > On Apr 10, 11:19 am, Anthony Crumley <[email protected]> > wrote: > > Doug, > > > > This may actually be worse but it is another way... > > > > <% begin %> > > <%= render :partial => 'custom' %> > > <% rescue ActionView::MissingTemplate %> > > Default > > <% end %> > > > > Anthony Crumleyhttp://commonthread.com > > > > On Fri, Apr 9, 2010 at 7:29 PM, doug <[email protected]> wrote: > > > Suppose that I want to have a block of default content within a > > > template that is replaced with the content of a specific partial only > > > if that partial exists. Obviously there is the brute force approach > > > of simply rendering the default content unless the relevant partial > > > file exists in which case the relevant partial is rendered instead. I > > > suspect that there may be a more elegant way to skin this cat. Any > > > suggestions? > > > > > Thanks for any input. > > > > > ... doug > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to [email protected] > . > > > To unsubscribe from this group, send email to > > > [email protected]<rubyonrails-talk%[email protected]> > <rubyonrails-talk%[email protected]<rubyonrails-talk%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

