I have the following code in my controller:
def list_by_so_number
if request.get?
@histories = History.find(:all, :conditions => ['so_number = ?',
params[:sales_order_number]], :order => 'timestamp desc')
if @histories.length < 1 then
flash[:notice] = 'There isn\'t a Sales Order that matches the
number you entered'
redirect_to :action => 'list_by_so_number'
end
end
end
My problem is that when I purposely enter a bogus so_number, I wind up
in a redirect loop, because of the redirect_to :action =>
'list_by_so_number' line.
How can I rewrite this so that when no histories are found, it'll
redirect to the list_by_so_number action, and notify the user?
Thanks,
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---