Newbie needs your help :D I want to figure out how to save parsed data from external api to database

Hi there!

I need your help

I need to figure out a way to save parsed data in my apps database.

Using nokogiri and open-uri I’ve managed to create an Array object with several hashes. All I want to do next is to save each hash object as a database entry.

I have a controller with all the CRUD actions, but I cant find a way to save each hash in my db.

Somehow I am frustrated and I cant seem to figure this out.

Thank you in advance

What exactly are you having a problem with? Storing a single hash, or storing multiple hashes during a single request, or ?

Do you have some code to show where you're blocked?

What exactly are you having a problem with? Storing a single hash,

or storing multiple hashes during a single request, or ?

Do you have some code to show where you’re blocked?

here’s my code class AnnouncementsController < ApplicationController require 'nokogiri' r - Pastebin.com

look for the profnews action

So what's not happening that you expect? Or happening that you don't expect?

I would probably move all that build logic into a service object to make it easier to test, but regardless, do you have a failing test for this?

If not, creating one would be a good place to start :slight_smile:

Have a look at the rails guide on debugging [1] for suggestions on how to work out what is/is not happening in your code

Colin

[1] Debugging Rails Applications — Ruby on Rails Guides

Thank you everyone for your efford to help me :smiley: It seems there was a problem with my routes, I managed to fix what I was supposed to do!

Thank you again!

Cheers!