Getting wrong id

B

Bla ...

I have the follow method:

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

@subtarefas = Subtarefa.find:)all, :conditions =>
["situacao_subtarefa = ? AND tarefa_id = ?", "Concluída",
@subtarefa.tarefa_id])
@tarefa = Tarefa.find:)first, :conditions => ["id = ?",
@subtarefa.tarefa_id])
num = (@tarefa.numero_previsto_subtarefas).to_i
if @subtarefas.size == num
@tarefa.situacao_tarefa = "Concluída"
@tarefa.data_conclusao = Date.current
@tarefa.update_attributes(params[:tarefa])

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


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?
 
B

BruceL

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top