Tips – variable in partial defined?
Posted by AllenWei | Posted in RubyOnRails, Tips | Posted on 15-02-2010-05-2008
View Comments
<% if foo.nil? %>
doesn’t work
assuming variable foo
There are two ways:
local_assignswill get all local variables, usinglocal_assigns[:foo],we can get variable value, If this variable is undefined, it will returnnil. Not Error.
defined?method
Using
defined? :foo


