Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3598088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:11:56+00:00 2026-05-18T20:11:56+00:00

I have a question. I’m parsing content using Nokogiri and my objective is to

  • 0

I have a question. I’m parsing content using Nokogiri and my objective is to process this content and insert in the database.

Table_rows contains parsed tr/tr elements and then I do Nokogiri’s node.content.to_a to get the td values I want.

(note: I need this column rec_id because I don’t know yet how to force id value when I insert hehehehe)

The code below generates an exception when it tries to save

  table_rows.each do |row|
    rec_id = row.content.to_a[0].strip.to_i

    if MyModelName.where(:rec_id => rec_id) == []
      MyModelName.init_from_array(row.content.to_a).save
    end

  end

init_from_array contains simple code like this:

def self.init_from_array(array)
  @mymodelname = MyModelName.new
  @mymodelname.field1 = array[0].strip #strip to avoid any empty
  @mymodelname.field2 = array[1].strip
  #and so on...
  @mymodelname
end

Inside controller I’m just calling this method between a begin and rescue. MyModelName don’t have any validation for now.

What I’m doing wrong to get this behavior – it generates a “cannot rollback, no transaction is active” but it saves the record to the database.

edit:

here’s the exception

SQLite3::SQLException: cannot rollback – no transaction is active from /opt/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.2/lib/sqlite3/database.rb:97:in close’ from /opt/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.2/lib/sqlite3/database.rb:97:inprepare’ from /opt/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.2/lib/sqlite3/database.rb:134:in execute’ from

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:11:57+00:00Added an answer on May 18, 2026 at 8:11 pm

    Solved the problem.

    The problem was with my migration file. Everything ran without problems but I had 1 migration for table creation and then more 3 migrations that added fields to this model. I don’t know yet how or why but I deleted all the migrations and started from scratch and now it saves without that error.

    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question, how can i insert a new data into a database that
I have just started using maven and have question. My pom.xml contains tag developer
I have a question related to this one . I don't want to do
I have question regarding shared memory segmentation in c using POSIX system calls. Is
I have question with this same title here but now as I'll present in
I have question about database optimizing, indexing. I have table that called projects and
I have question I'm developing small application to desktop in win Forms. I'm using
I have question regarding polymorphism about its assignment statement, for Example this is The
I have a question regarding inheritance in Java. If I have this base class
ok i have question, i made this code to play axmediaplayer base on item

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.