Possible Duplicate:
NoMethodError (undefined method `[]' for nil:NilClass)
I am new to rails 3, and I am trying to render something to an HTML form:
<td class="kanban-task-handler">by: <%=h (!@tasks[activity['taskid']]['assignee'].nil? ? @tasks[activity['taskid']]['assignee'] : '') %></td>
but I’m getting this error:
undefined method `[]' for nil:NilClass):
but I’m checking this variable and stating if it’s nil–> then print out nothing…
so why isn’t this working?
I’m not sure what you’re trying to do here, but it seems like @tasks is nil here. You could just check it with @tasks.nil?
But remember, if the @tasks is an array it will not give you nil? -> true instead you need to use <
Array>.empty?A safer way of checking this is: