레일에서 게시물 (사진)을 파괴하려하지만 게시물의 표시 페이지로 계속 이동합니다.레일에서 게시물을 삭제할 수 없습니다.
보기/사진/index.html.erb
<td><%= link_to 'Destroy', photo, method: :delete, data: { confirm: 'Are you sure?' } %></td>
루트
resources :photos
resources :billets
devise_for :users
get 'information/index'
get 'information/afficher'
root to: 'information#index'
get "*path" => redirect("/")
로그 바로 내가 조치를 파괴의 나 사진 '인덱스
Started GET "/photos/1" for 127.0.0.1 at 2014-05-23 19:13:22 -0400
Processing by PhotosController#show as HTML
Parameters: {"id"=>"1"}
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
Photo Load (0.1ms) SELECT `photos`.* FROM `photos` WHERE `photos`.`id` = 1 LIMIT 1
------------ With this action I will SHOW the given Photo------
Rendered photos/show.html.erb within layouts/application (0.8ms)
Completed 200 OK in 13ms (Views: 9.9ms | ActiveRecord: 0.2ms)
에 파괴를 클릭하면
def destroy
puts "With this action I will destroy the given Photo"
@photo.destroy
respond_to do |format|
format.html { redirect_to photos_url }
format.json { head :no_content }
end
end
그것은 소리 당신이 파괴 행동에 얻을 PARAMS에 따라 이동 위치를 결정 나에게 링크를 클릭하면 'DELETE'가 실행되지 않는 것을 보장하는 자바 스크립트를 좋아한다. 'method :: delete'가 없다면, 그것은 단지'show' 액션에 대한 링크 일뿐입니다. 확인 대화 상자가 나타 납니까? –
아니요 확인이 터지지 않습니다. –
좋아, 내 이론을 뒷받침 해줍니다. 링크가 'DELETE'를 수행하게하는 코드는 확인 팝업 ([jquery_ujs] (https://github.com/rails/jquery-ujs))을 생성하는 코드입니다. Javascript 콘솔에 오류가 있습니까? 'application.js'에'// = jquery_ujs require '이 있습니까? –