Neeraj Kumar
2007-Nov-29 15:28 UTC
render_404 and return not working but it works if I split it in two lines
Following code works
@vendor = Vendor.find(:first, :conditions => {:status => 1, :id =>
params[:id]})
unless @vendor
render_404
return
end
**
*However this code fails.*
*
@vendor = Vendor.find(:first, :conditions => {:status => 1, :id =>
params[:id]})
unless @vendor
render_404 and return
end
with following error message.
Called id for nil, which would mistakenly be 4 -- if you really wanted the
id of nil, use object_id
I have seen people use do something and return. Why my code is failing.
*
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Greg Donald
2007-Nov-29 15:41 UTC
Re: render_404 and return not working but it works if I split it in two lines
On Nov 29, 2007 9:28 AM, Neeraj Kumar <neeraj.jsr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @vendor = Vendor.find(:first, :conditions => {:status => 1, :id => > params[:id]})@vendor = Vendor.find( :first, :conditions => [ ''status = 1 AND id ?'', params[:id] ] ) -- Greg Donald http://destiney.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Raj Singh
2007-Nov-29 16:10 UTC
Re: render_404 and return not working but it works if I split it in two lines
I know I should sanitize the user input. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---