Rails 3.0 Parsing XML and Inserting into Database

后端 未结 3 2009
星月不相逢
星月不相逢 2021-02-11 08:48

I\'m new to Rails, and am trying to hook up my application to a third-party API (it does\'t have a gem or plugin for Rails).

Ideally, what I want to be able to do is par

3条回答
  •  梦毁少年i
    2021-02-11 08:52

    I just see your log and find out that your Event model do have has_many realtion with Town Model and also consists town_id column in your event table . SO i think that might be the problem as its trying to get the town_id and save the foreign key of town in your event table . But as it doesn't get any so it's always rollback . Also if you want then try to **

    @data.save!

    instaed of

    @data.save

    thanks

提交回复
热议问题