0

我fork了一个gem并改变了一些东西,但我真的很绝望。我总是得到模板丢失:

模板丢失缺少模板 spree/addresses/index、spree/store/index、spree/base/index、application/index with {:locale=>[:de, :en], :formats=>[:html], : handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :haml, :rabl], :versions=>[:v1]}。在以下位置搜索:*“/Users/Manu/Documents/rails_projects/my_store_dev/app/views”*“/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_my_favourites-6076d6ee5cb2/app/views” * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_address_book-b66e2abf6429/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/ gems/spree-promotion-roles-rule-0fd33e96c5c4/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-promotion-exclude-specials-rule-1debc9765387/应用程序/视图" * "/Users/Manu/.rvm/gems/ruby-2.1.

这是我的路线文件:

Spree::Core::Engine.routes.draw do
  # Add your extension routes here
  namespace :account do
    resources :orders, only: [:index]
    resources :favourites, only: [:index]
    resources :addresses, only: [:index]
  end

end

这是我AddressesControllercontroller/spree/account/

module Spree
  module Account
    class AddressesController < Spree::StoreController

  before_filter :check_logged_in_user

  def index
    @user = try_spree_current_user

  end

  private

  def check_logged_in_user
    unless try_spree_current_user
      account_addresses__path 
      redirect_to spree_login_path 
    end
  end

  end
 end
end

我有一个index.hamlin views/spree/account/addresses/,这是 rake 路线的一部分:

account_orders GET    /account/orders(.:format)                                     spree/account/orders#index
account_favourites GET    /account/favourites(.:format)                                               spree/account/favourites#index
account_addresses GET    /account/addresses(.:format)                                                spree/account/addresses#index

有人可以给我一个提示吗?

4

3 回答 3

3

我有类似的经历,不确定这是否适用于您,但这里是:

这是我得到的错误:

ActionView::MissingTemplate at / . 
Missing partial spree/shared/_google_analytics with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :haml, :jbuilder, :rabl], :versions=>[:v1]}. Searched in:
* "/Users/sjones/work/cs-spree/app/views"...

但事实证明,部分确实存在,甚至正在被解析和运行(我使用 RubyMine 调试器来检查)

错误是不正确的。在我的情况下,控制器中缺少一个辅助方法try_spree_current_user,并且这个丢失的方法NoMethodError错误以某种方式被捕获并替换为MissingTemplate显示的错误。

修复该错误导致模板加载得很好。

就像我说的,这可能不是你的问题,但这太奇怪了,我正在为其他人发布这个。

于 2017-05-26T16:27:00.643 回答
2

安装扩展spree_theme后出现此错误

Missing partial spree/shared/_google_analytics

我最终在这里找到了文件(所以它根本没有丢失):public/vinsol_spree_themes/current/views/spree/shared/_google_analytics.js.erb

在调试了一下之后,终于检测到了一个缺少的class not defined类型错误,Spree::Tracker所以我所要做的就是修复该依赖关系并且事情起作用了,正如stujo上面提到的那样,有时似乎这条消息与文件本身无关,而是与外部原因有关

3.5这就是我从头开始生成我的项目的方式

从头开始安装底座

** 假设您有一个空的 rails 应用程序 **

更新 Gemfile

gem 'spree', '~> 3.5.0'

gem 'spree_auth_devise', '~> 3.3'

gem 'spree_gateway', '~> 3.3'

安装开发依赖

1)bundle update i18n(我认为这是可选的,但不确定)

2)bundle install

安装安装生成器以设置 Spree:

1)rails g spree:install --user_class=Spree::User

系统将要求您设置管理员帐户 Email [spree@example.com]: admin@cucg.com Password [spree123]:

然后就跑rails s,你就准备好了

我只是按照这个Spree 官方安装指南,一切都很好

于 2018-06-22T05:48:52.100 回答
0

您需要将 html 包含到您的 haml 文件名中。

像这样:

your_file_name.html.haml

将您的索引文件重命名为:

index.html.haml

在此处阅读有关haml的更多信息:

http://haml.info/tutorial.html

于 2014-11-05T00:57:57.740 回答