2012-12-08 6 views
0

ID 전달 방법.컨트롤러의 ID를 전달하는 방법

class AttachementsController < ApplicationController 
    def index 
    @pdf = Attachement.find(params[:resume_id]) 
    # send_file(@pdf.file.url, :type => 'application/pdf', :disposition => 'inline',:stream => false) 
    redirect_to @pdf.file.url 
    end 
end 

및 컨트롤러의 내 테스트 케이스는 다음과 같습니다 : 내 컨트롤러는

require 'spec_helper' 

describe AttachementsController do 

    describe "GET 'index'" do 
    it "should be successful" do 
     get 'index', :id => "@attachements.id" 
     response.should be_success 
    end 
    end 

end 

내 오류는 다음과 같습니다

AttachementsController GET 'index' should be successful 
    Failure/Error: get 'index', :id => "@attachements.id" 
    ActiveRecord::RecordNotFound: 
     Couldn't find Attachement without an ID 
    # ./app/controllers/attachements_controller.rb:3:in `index' 
    # ./spec/controllers/attachements_controller_spec.rb:7:in `block (3 levels) in <top (required)>' 

답변

0

당신은 @attachements 주위에 따옴표가 필요하지 않습니다. 신분증.

get 'index', :id => @attachements.id 
+0

필요할 수도 있습니다. 대신 resume_id : id – Phlip

관련 문제