Redirect_to difficulties

I’ve been working on a create function that takes some information from
the user, compares it against existing records and, based on the results
of that comparison, decides how to act.

There is also the chance that if none of the user records match, the
system does nothing. The user’s new input is not saved, and the user is
just returned to the list page.

Everything works perfectly - including the if and elsif portions.

What is not working is that last: redirect_to :action => ‘list’

If the function cycles through all of the Master records and still has
not found a match, it should redirect back to the list without saving.
Unfortunately, it keeps sending the user to create.rhtml page instead.

Any ideas? :confused:

def create
@contact = Contact.new(params[:contact])

Master.find(:all,  :conditions => { :firstname =>

@contact.firstname,
:lastname => @contact.lastname
}).each do |master|

    if (Some Criteria)
           Various actions are in here but omitted.
           @contact.save
           redirect_to (:action => 'list', :id => @contact) and

return

    # If not, does the entry match the Level 2 criteria?
    elsif (Some Criteria)
           Various actions are here, too.
           @contact.save
           redirect_to (:action => 'list', :id => @contact) and

return

    end

redirect_to :action => 'list'

end

end

Nevermind. I had the redirect_to up on END more than it should have been
:frowning:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs