From: "Bla ..." Date: 2010-07-29T22:44:57+09:00 Subject: 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 @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? -- Posted via http://www.ruby-forum.com/.