Bla ... wrote:
> I've done this:
> 
> def update
>     @projeto = Projeto.find(params[:id])
> 
> ## Here it finds one "permissao" with the user that i choose, the 
> profile that i choose and the project that i choose.
>     @ex_permissaoI = Permissao.find(:first, :conditions => ["usuario_id 
> = ? and perfil = ? and projeto_id = ?", Usuario.find(:first, :conditions 
> => ["id = ?", @projeto.responsavel_td.to_i]), "Intermediário", 
> @projeto.id])
>     @ex_permissaoB = Permissao.find(:first, :conditions => ["usuario_id 
> = ? and perfil = ? and projeto_id = ?", Usuario.find(:first, :conditions 
> => ["id = ?", @projeto.coordenador.to_i]), "Intermediário", 
> @projeto.id])
> ## Here it should destroy those "permissao"
>     @ex_permissaoI.destroy
>     @ex_permissaoB.destroy
> 
>     if (@projeto.update_attributes(params[:projeto]))
> (...)
> end
> 
> And I get this error:
> 
> You have a nil object when you didn't expect it!
> You might have expected an instance of ActiveRecord::Base.
> The error occurred while evaluating nil.destroy

Well, which @ex_permissao is the nil one?  Obviously, one or both of 
your finds are failing. You should try running that code in irb to make 
sure that the conditions you are constructing are actually returning 
something.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to