I'm in Ruby 1.9.3 for my Rail 3.2.11 app in the last day or so for every SO post this Read about that I can do. It looks closer to writing down this record because I have taken action due to such responses. I have an object and I want to write a value record which is related to the object. To learn about how to create the original API, I wrote a namespace and a different value controller.
After attempting to use the build action to be used for HTML in that controller, I bailed on that approach and just added Commodity_ID to the JSON call because I used the CommodityId I'm hoping to keep My updated AP :: Price Controller # has a basic value in the price value model.
Commodity. Rb
class commodity < ActiveRecord :: Base attr_accessible: Description ,: name has_many: accepts for prices_nested_data_price: price.rb
class price < ActiveRecord :: Base Attr_accessible: Buyer, Date, Price: Quality, Commodity_ID related_to: End of object prices_controller.rb
Class value controller & lt ; api / prices_controller.rb
/ p>
Module API class value controller & lt; ApplicationController response_to: Answer with JSN DER value.Cure (parameter [: price]) End and end path.rb
Namespace: Resource: Prices End End This is my curl call: API, default: {Format: 'json'} Resources: commodities, only: [: show,: new, create]
Accept: Application / Jason "-H" Content Type: Application / Jason "-X POST http: // localhost: 3004 // api / commodities / 1 / Prices Json -d "{\" price \ ": {\" prices_attributes \ ": [{\" price \ ": 8, \" purchase R \ ": \" Sam \ ", \" quality \ ": \" bad \ ", \" commodity_id \ ": 1}]}}" is the answer "secure Properties can not be extensively assigned: prices_attributes "
OK, I believe I should be able to do this because another post says that unless I have not been created Has been updated from time to time, I should be good. But i do not In another SEO I got to do JSON calls like an ARL call as a similar poster and work to wrap it in the scope of prices. Pointing to this cover it looks like this:
Accept the curl-V-H: Application / Jason "-H" Content Type: Application / Jason "-X post http : // localhost: 3004 // API / commodities / 1 / prices. Jason-D "{\" Price \ ": {\" Price \ ": 8, \" Buyer \ ": \" Sam \ ", \" Quality \ ": \" Bad \ ", \" Commodity_id \ ": 1}} " For the price controller," undefined method returns `value_ar." Why does not it seem?
Value is not nested value and there is no value in the model of the price, accepts: the commodity has JSON bad in which You are trying to save nested properties inside the value model In the first example, your JSON should look like this: ... {\ "commodity \": {\ "prices_attributes \": [{\ "price \": 8, "Buyer \": \ "Sam \", \ "quality \": \ "bad \", \ "commodity_id \": 1}]} "JSON" in JSON. Second JSON is completely incorrect.
Read more about the better understanding of nested features in the rail.
No comments:
Post a Comment