2011-07-03 2 views
50

Rails 3.1 앱의 일부 외부 이미지 (jQuery 플러그인에서 사용)를 공급 업체/자산/이미지에 넣으려고합니다. Rails 3.1 공급 업체/자산/이미지의 이미지 제공

No route matches [GET] "/assets/ui-bg_flat_75_ffffff_40x100.png" 

내가 내 Rails.application.config.assets.paths을 확인하고이 DIRS 목록 :

..../app/assets/images 
..../app/assets/javascripts 
..../app/assets/stylesheets 
..../vendor/assets/images 
..../vendor/assets/stylesheets 
..../.rvm/gems/[email protected]/gems/jquery-rails-1.0.9/vendor/assets/javascripts 

<%= image_tag "ui-bg_flat_75_ffffff_40x100.png" %> 

나는 오류가 발생 : 문제는 내가 뭔가를하려고 할 때이다

/vendor/assets/images를 볼 수 있습니다. app/assets/images에 이미지를 넣으면 모든 것이 작동합니다.

나는 새로운 자산 파이프 라인이 모든 자산 디렉토리를 거쳐서 어디서나 요청 된 파일을 제공한다고 생각했다.

여기에 어떤 문제가 있는지 아는 사람이 있습니까?

+0

죄송합니다. 귀하의 문제를 정확하게 도와주지는 않지만 Rails.application.config.assets.paths는 어떻게 볼 수 있습니까? – Martin

+1

@martin : 콘솔에서 볼 수 있습니다 –

+0

이것은 바보 같은 질문 일지 모르지만 이미지 디렉토리의 jqueryui 자산입니까? Mine은 이미지 디렉토리에 있고, jqueryui의 theme maker가 생성하는 CSS 경로를 유지하기 위해 자신의 서브 디렉토리에있다. – Slick23

답변

80

vendor/assets/images 디렉토리를 만든 후에 레일 서버를 다시 시작해야했습니다. 그 전에는 ("경로가 일치하지 않습니다 [GET]") 동일한 오류가 표시되었습니다.

제가 처음 시작할 때 레일스 서버가 존재하지 않았다면 레일즈 서버는이 디렉토리를 검사하지 않습니다. 문제를 진단하기 위해 레일 콘솔을 열면 디렉토리에 대해 알고있는 레일스의 새로운 인스턴스가 생겨 혼란에 가중됩니다.

+1

재시작이 트릭을 수행했습니다. 감사! –

+0

Pow (그리고 powder gem)을 사용하여 나는 단지 운이없는 'powder restart'을 시도했다. 그런 다음 'powder down'과 'powder up'을 시도했고, 마지막으로 Rails.application.config.assets.paths에는 vendor/assets/images가 포함되었습니다. – Chris

+1

'powder restart'이 나를 위해 속임수를 사용했습니다 – Cristian

9

자산 파이프 라인은이 안내서의 Ryan Bigg (현재 초안 상태)에 설명되어 있습니다.

http://ryanbigg.com/2011/06/sprocket-asset-tags-internals/을 참조하십시오.

이에 따르면 예제가 효과가 있습니다.

추출 : 당신 작품으로

Assets can be placed inside an application in one of three locations: app/assets, lib/assets or vendor/assets.

app/assets is for assets that are owned by the application, such as custom images, javascript files or stylesheets.

lib/assets is for your own libraries’ code that doesn’t really fit into the scope of the application or those libraries which are shared across applications.

vendor/assets is for assets that are owned by outside entities, such as code for JavaScript plugins.

Any subdirectory that exists within these three locations will be added to the search path for Sprockets (visible by calling Rails.application.config.assets.paths in a console). When an asset is requested, these paths will be looked through to see if they contain an asset matching the name specified. Once an asset has been found, it’s processed by Sprockets and then served up.

내 응용 프로그램의 예와 같은 구문을 테스트했습니다. 어쩌면 자산 이름에 오타가있을 수 있습니다.

Martin의 경우 : Sprockets의 검색 경로는 Console의 Rails.application.config.assets.paths를 호출하여 볼 수 있습니다.

+0

예, 읽었습니다. 그래서 그것이 효과가 있다고 생각하는 이유입니다. 어쩌면 그것은 버그 일 것입니다. –

+0

나를 위해 그것이 작동합니다. 자산 이름을 테스트로 변경하려고 시도 했습니까? –

+0

이것은 내 모든 응용 프로그램에서 반복되는 문제입니다. Rails 3에서 빌드합니다. – botbot

22

jQuery UI 테마 롤러 테마를 사용하는 경우 문제는 jquery-ui css 파일에서 이미지가 하위 폴더 '이미지'내에서 참조되는 것일 수 있습니다.

e.e. 당신은 당신의 이미지를 './app/assets/images/images' 폴더에 넣거나 jquery-ui css 파일을 편집하고 'images /'폴더 접두사를 제거해야합니다.

+8

'GET http://example.com/assets/images/darrowleft.gif 404 (Not GET)가 표시 될 수도 있습니다. 발견)'자바 스크립트 콘솔에서'vendor/assets/images'에 그 이미지가 있습니다. 그러나 URL에 대해 http : // example.com/assets/darrowleft.gif를보아야합니다. 'http : // example.com/assets/images/darrowleft.gif'를 보려면 @woelfle 설명대로 해당 이미지를'vendor/assets/images/images'에 넣어야합니다. 이렇게하면 연결된 CSS 파일의 경로를 수정해야하는 번거 로움을 줄일 수 있습니다. –

+0

이미지라는 또 다른 폴더에 이미지를 넣는 것이 이상하게 보이지만 레일 3.1.3에서 나를 위해 일했습니다. 감사! – counterbeing

+0

고마워, 조지, 그게 내게 필요한 퍼즐 조각 이었어! – Sprachprofi

2

어쩌면/assets/images에 다른 폴더를 만들어야 할 수도 있습니다. '이미지'라는 이름을 만든 다음 모든 jquery-ui 이미지를 복사하고 이전에 만든 폴더 '이미지'에 붙여 넣으십시오. 바라기를 이것은 당신을 도울 것입니다.

관련 문제