나는 사람이 매개 변수로 이름을 취하고 그 사람을 찾으면 오류 메시지가있는 searchPerson.html.erb를 렌더링하는 search searchPerson을 가진 컨트롤러 담당자가 있습니다.레일즈 URL 재 작성
내가 수행 할 때 내가 페이지 searchPerson.html.erb 을 볼 수 있습니다 http://localhost/person을 입력하지만 때 난 항상 내가
map.connect "person/", :controller => 'person', :action => 'searchPerson'
그래서 경로를 추가 http://localhost/person 대신 http://localhost/person/searchPerson
의하고 싶은 검색자가 렌더링하고 검색하는 URL은 http://localhost/person/searchPerson
내 기능 검색 사용자
def searchPerson
flash[:error]=nil
@name=params[:name]
#if a name is provided
if(@name!=nil)
#trying to find the person with the name
ret = Person::lookup @name
#error, the person cannot be found
if ret[:err]
flash[:error]="We could not find this person"
#person found, user is redirected to the person details
else
redirect_to url_for(:controller => 'person', :action => 'details', :id => ret[:person].id)
end
end
end
어떻게 피할 수 있습니까? 감사