Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Send results back to API

shopify api PUT

  • Please log in to reply
1 reply to this topic

#1 benh4889

benh4889

    Passenger

  • Members
  • 2 posts

Posted 21 April 2014 - 07:47 PM

Hi,

 

Im currently in the process ( Very Early ) of leaning Ruby on Rails. Im currently a Front End Dev at a web design company.

Im having what im positive is a very newbie question however im really struggling with it. 

 

Basically i have my application set up to interact with the Shopify API ( Thats all working perfect )

 

I have it set up at the moment to pull through 10 products and then i loop through to display them: @products = ShopifyAPI::Product.find(:all, :params => {:limit => 10})

 

Im basically trying to work out in general terms, how do you post back the results back to Shopify if a made a change to say the title in my application. e.g. I have a form on my application where i can change the title of a product, click save, and that is posted back to shopify and make the change on there system. 

 

The response they expect is: 

 

PUT /admin/products/#{id}.json{
"product": {
"id": 632910392,
"title": "New product title"
}
}

 

I can populate that no problem, i just cant work out how to post those results back to shopify. 

 

Is there a PUT method in ruby on rails?

 

Thanks for any help, like i said im very new to RoR but im eager to learn

 

Cheers

 

Ben



#2 th3mus1cman

th3mus1cman

    Signalman

  • Members
  • 14 posts
  • LocationRichmond, VA

Posted 03 June 2014 - 02:26 PM

Since you are using the Shopify Gem try: 

product = ShopifyAPI::Product.find({product_id})
product.title = 'New Title'
product.save

Rails Developer and Partner at Left + Right






Also tagged with one or more of these keywords: shopify, api, PUT

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users