Reputation: 1035
I need to get the current shop's domain (I do this using ShopifyAPI::Shop.current.domain
). This works in the HomeController and can display it in home/index.html.erb
. But, when I try to call ShopifyAPI::Shop.current.domain
in my CustomController to display in a different view, I get the error Missing site URI
.
I think this is because once the user leaves the home/index view it no longer has access to that Shop instance. So, how can I recreate that instance in my CustomController if I don't know the id. For example, this works:
@shop = Shop.find(1)
@domain = @shop.shopify_domain
But, I will not always know the shop's id
in the model.
Or, maybe I am approaching this the wrong way.
Upvotes: 1
Views: 972
Reputation: 36
Late to the party but using around_filter :shopify_session
in your controller should fix this. If it doesn't, ensure that the controller is inheriting from the AuthenticatedController
.
Example:
class CustomerController < AuthenticatedController
around_filter :shopify_session
def shops
@shop = ShopifyAPI::Shop.find(1)
end
end
Upvotes: 2