Getting wrong id

I have the follow method:

def concluir
@subtarefa = Subtarefa.find(params[:id])
@subtarefa.situacao_subtarefa = “Concluída”
@subtarefa.data_termino_real = Date.current

@subtarefas = Subtarefa.find(:all, :conditions =>

[“situacao_subtarefa = ? AND tarefa_id = ?”, “Concluída”,
@tarefa = Tarefa.find(:first, :conditions => [“id = ?”,
num = (@tarefa.numero_previsto_subtarefas).to_i
if @subtarefas.size == num
@tarefa.situacao_tarefa = “Concluída”
@tarefa.data_conclusao = Date.current

@tarefas = Tarefa.find(:all, :conditions => ["situacao_tarefa = ?

AND projeto_id = ?", “Concluída”, @tarefa.projeto_id])
@projeto = Projeto.find(:first, :conditions => [“id = ?”,
num2 = (@projeto.numero_previsto_tarefas).to_i
if @tarefas.size == num2
@projeto.situacao_do_projeto = “Concluído”
@projeto.data_conclusao = Date.current
render :action => “show”
flash[:msg] = “Subtarefa concluída com sucesso”

My problem is:

undefined method `projeto’ for nil:NilClass

It gets the subtarefa’s id instead of tarefa’s id when i’m loking for a
tarefa in Tarefa class.
If it don’t get any tarefa with the subtarefa’s id (and it shouldn’t,
'cause isn’t the right id), @tarefa will be a nil object, haven’t, that
way, the “projeto_id” method.

What am i missing?

actually, the problem is in here:

def verificai?
@permissaoI = Permissao.all(:conditions => ["usuario_id = ? AND
perfil = ? AND (projeto_id = ? OR projeto_id = ? or projeto_id = ?) ",
session[:usuario_id], “Intermediário”, Subtarefa.first(:conditions =>
[“id = ?”, params[:id]]), Tarefa.first(:conditions =>
[“id = ?”, params[:id]]), params[:id]])
if !@permissaoI.blank?
return true
return false

when I get undefined method `projeto’ for nil:NilClass

it is almost always because I misspelled something or got the
capitalization wrong
if that helps

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs