When i try to update the access token on a ShopifyShop object in my database i get:
undefined method api_version' for #<ShopifyShop:0x00007ff590685348
My code is just:
shop.update_attributes(shopify_token: token) if shop
In my ShopifyShop model i do include include ShopifyApp::SessionStorage
Anyone know why this error keeps being thrown?
yes me too.
@iamricks @heldopslippers
I got similar issue during upgrade to the latest shopify_app gem version.
I regenerated code with $ rails generate shopify_app:install and also did these https://github.com/Shopify/shopify_app#upgrading-from-86-to-900 changes and now it's all working for me.
@iamricks @heldopslippers did @andreas-sotnik-2k19鈥檚 solution work for you?
@nwtn Just tested it.
After following these instructions it worked:
Configuration change
Add an api version configuration in config/initializers/shopify_app.rb Set this to the version you want to run against by default. See Shopify API docs for versions available.
config.api_version = '2019-04'
Session storage change
You will need to add an api_version method to you session storage object. The default implmentation for this is.
def api_version
ShopifyApp.configuration.api_version
end
My fault for not reading the changelog.
@iamricks hey im having the same issue - i cant for the life of me figure out where I'm supposed to put
def api_version
ShopifyApp.configuration.api_version
end
could you help me out?
a little more info..
in my shopify_app file i have included this
config.session_repository = Shop
config.api_version = '2019-04'
and in my shop.rb file ive tried this
class Shop < ActiveRecord::Base
include ShopifyApp::SessionStorage
def api_version
ShopifyApp.configuration.api_version
end
and it returns the same error
NoMethodError: undefined methodapi_version=' for #
@seshna Have you figured it out? I have the same issue...
@Rasovsky my shopify_app and shopiy_api gems both needed to be updated, and with the code i wrote above, it worked.
Most helpful comment
@nwtn Just tested it.
After following these instructions it worked:
My fault for not reading the changelog.