On 14 Oct 2008, at 22:03, Pod Caster wrote:

>
> Hi,
>
> I wondering about the next:
>
> The book Advance Rails states that using
>
>  def show
>    @message = Message.find_by_user_id_and_id(current_user.id,
> params[:id])
>  end
>
> Should return RecordNotFound if the user that tries to view a  
> message is
> not the one that created it.

That's just not what find_by ... does. It behaves more like find :first

Fred
>
>
> But what I get is:
>
> You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.sender_name
>
> And that is fine since it gets to the view and the @message used there
> is nil.
>
> But the find_by_user_id_and_id was not returning RecordNotFound. Which
> is something I could use a common error page for.
>
> I'm I missing something?
>
> Thanks.
> -- 
> 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