1
을 사용하여 Rails 3.2.18
을 사용하여 새로운 컨트롤러이며 라우팅에이 컨트롤러를 추가하려고합니다. 기존 형식이 내가 읽은 자습서와 다르기 때문에이 작업을 수행하는 방법을 잘 모릅니다.레일 경로 - 컨트롤러 메서드를 추가하여
resources :devices, :only => [:index, :show, :update] do
member do
put :backup
put :refresh
end
collection do
get :find
end
컨트롤러 조각 :
를가device_text_search
해당
/devices/deviceTextSearch
포인트가 될 것입니다 및보기가
device_text_search_path
경로 조각 조각하여 참조 할 수 있도록 컨트롤러 메소드 이름을 추가 할 위치를 모르겠어요
# GET /devices/find
def find
device = current_domain.device.find_by_logical_name(params[:device_id].strip)
respond_to do |format|
if device.nil?
flash[:notice] = "Device '#{params[:device_id]}' was not found"
format.html { redirect_to devices_path }
else
format.html { redirect_to device_path(device) }
end
end
end
#GET /devices/deviceTextSearch
def device_text_search
if params[:q].nil?
@device_text = []
else
@device_text = DeviceTextSearch.search params[:q]
end
end