Shopify路线错误:取消定义shopify_api_ [resource] _path

时间:2019-06-12 22:57:41

标签: ruby-on-rails shopify-app

目前,我正在学习创建Shopify自定义应用。我正在研究元领域。可以通过以下方式创建元字段

@metafield = ShopifyAPI::Metafield.new()

在表单视图中,我使用

<%= bootstrap_form_for @metafield do |f| %>
<% end %>

该表格要求我定义shopify_api_metafields_path等。

是否可以在不向控制器添加shopify_api模块的情况下为路由resources :metafields定义前缀ShopifyApi::

2 个答案:

答案 0 :(得分:1)

您可以尝试:

resources :shopify_api_metafields, controller: :metafields

哪个会给你:

    shopify_api_metafields GET    /shopify_api_metafields(.:format)               metafields#index
                           POST   /shopify_api_metafields(.:format)               metafields#create
 new_shopify_api_metafield GET    /shopify_api_metafields/new(.:format)           metafields#new
edit_shopify_api_metafield GET    /shopify_api_metafields/:id/edit(.:format)      metafields#edit
     shopify_api_metafield GET    /shopify_api_metafields/:id(.:format)           metafields#show
                           PATCH  /shopify_api_metafields/:id(.:format)           metafields#update
                           PUT    /shopify_api_metafields/:id(.:format)           metafields#update
                           DELETE /shopify_api_metafields/:id(.:format)           metafields#destroy

答案 1 :(得分:0)

我通过定义从 public string Decimal { get { return Number.Decimal; } set { if (Number.Decimal != value) { Number.Decimal = value; RaisePropertyChanged("Decimal"); } } } 继承的模型Metafield提出解决方案,然后定义ShopifyAPI::Metafield而不是@metafield = Metafield.new

通过这种方式,以后管理起来会更容易,并且它还使我们能够同步数据表。