Working with the asset API (Ruby on Rails)

New Member
27 0 0

Hey guys

I'm having a bit of trouble configuring my web-app (Ruby on Rails) to work with the shopify API and I'm hoping some of you clever people can help me out! :-) 

I managed to set up a Ruby on Rails web-app for my shopify (test) store succesfully, using the shopify_api gem. It's installed, it's running and I'm able to manipulate content.

I feel however, like the documentation  is somewhat lackluster and I can't seem to figure why the app is throwing me an error every time I try to add any of hte following code.
I feel like I should have correctly set up this code, but I'm at wits end.

I added code to my controller, view and initializer (adding scope for grabbing asset).

Controller:

@assets   = ShopifyAPI::Asset.find(:all)

View:

<%= link_to asset_title, "https://#{@shop_session.url}/admin/themes/#{id}/asset.json?asset[key]=snippets/superdropdown.liquid" %>

Scope:

config.scope = "read_orders, read_products, read_themes, write_themes"

I have also read and re-read both the (ruby) gem documentation as well as the API documentation a bunch of times to make sure I understand correctly.

However I am just getting a http 500 status, which is an error.

I really don't know where to go from here as I believe I have set everything up correctly. Or have I?

Any help MUCH appreciated :-)

Best
Martin

0 Likes
Highlighted
Shopify Partner
27 0 2

Hi Martin,

 

Have you got any luck fixing above issue? I am stuck on the same one.

 

Cheers!!

0 Likes

Just a thought, but are you trying to retrieve more than 250 objects when you try to find "all"?

https://help.shopify.com/api/getting-started/api-call-limit

Another thought is that I ran into an issue trying to use a "shop_session.url" link, and eventually fixed it using back ticks instead of double quotes for the link. This was in a React component, so maybe not the same, but here is an example:

`https://${data.shop_session.url}/admin/products/${product.id}`

 

 

 

Theme and app development | Toronto, Canada | sizzlecentral.com
0 Likes
Shopify Partner
27 0 2

Hi Guys,

I have figured it out and have written on it  see http://www.navinbista.com/shopify-asset-api/ .

It mention the detail on accessing it and using it on rails public app.

Please have a look and share your feedback on comments.

Regards,

Navin 

0 Likes