在rails引擎中使用image_tag

时间:2017-07-14 19:09:39

标签: ruby-on-rails image asset-pipeline rails-engines

image_tag("cheese.png")位于my_engine时,为什么不assets/images/my_engine/cheese.png加载我的视图中的图像(@Override public boolean onTouch(View v, MotionEvent event) { // we only want to handle this on DOWN or MOVE (drag) int action = event.getAction(); if(action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) { Log.d(TAG, "Starbar touched; current rating=" + getRating()); // do stuff for UI purposes here // capture the current rating before onRatingChanged does anything currentRating = getRating(); } if(action == MotionEvent.ACTION_UP) { Handler handler = new Handler(Looper.getMainLooper()); final Runnable r = new Runnable() { public void run() { float newRating = getRating(); if(currentRating == newRating) { Log.d(TAG, "Same rating tapped; would unrate"); // do something UI related here } else { Log.d(TAG, "New rating, will just show it"); // this just falls through to my onRatingChanged() } } }; handler.postDelayed(r, (long) 0.1); } // allow the touch event to propagate return false; } 内)?

1 个答案:

答案 0 :(得分:0)

@Simrayz - 我需要看到更多的目录结构才能完全理解,但一般来说,rails中的图像路径并不依赖于您的视图结构。它取决于资产图像目录结构。

因此,如果您有assets / images / my_engine / cheese.png,则可以从任何视图使用路径my_engine / cheese.png访问它,无论视图文件的目录结构如何。