Hi Russell,
Can you be more clear about what IS happening when you try to save your new item?
I'm guessing the lines of code involved are lines 185-193 in https://github.com/russellmiller3/CouchRocket/blob/master/CouchRocket.rb
@item = Item.new(item_attrs)
@item.original_price = To_Cents(@item.original_price)
@item.asking_price = To_Cents(@item.asking_price)
@item.save!
@item.errors.each do |error|
puts error
end
- What does
@item
point to on the line AFTER you set it equal to the call toItem.new()
? - What happens if you insert a
binding.pry
on the line after you set the value ofasking_price
and call@item.valid?
? - Adding the
!
to your call to.save!()
tells the ORM to return validation/save errors back to you, what happens if you change your call tosave!
toputs @item.save!
?
In the general sense, is there a difference between printing the return value of @item.save!
and iterating through the .errors
object and printing the contents (I don't know personally but this seems like an opportunity for exepcation and actuality to diverge)?
Maybe investigate my questions above and post back in this gist (or another one) some screenshots or terminal outputs?
❤️ JD
Some really useful tips, thanks John!