Search code examples
ruby-on-railsshopify-app

Shopify Route Error: undefine shopify_api_[resource]_path


Currently I am learning to create a Shopify custom app. I am working on metafields. A metafield can be created by

@metafield = ShopifyAPI::Metafield.new()

In form view, I use

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

The form requires me to define shopify_api_metafields_path etc.

Is there a way to define prefix shopify_api to my routes resources :metafields without adding ShopifyApi:: module to my controller?


Solution

  • I come up with solution by defining a model Metafield which inherit from ShopifyAPI::Metafield and then, I define @metafield = Metafield.new instead of @metafield = ShopifyAPI::Metafield.new

    By this way, it will be easier to manage later and it allow us to synchronize data table as well.