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 7916901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:58:30+00:00 2026-06-03T14:58:30+00:00

I’m learning ruby on rails by following Patrick Lenz’s book from Sitepoint. I know

  • 0

I’m learning ruby on rails by following Patrick Lenz’s book from Sitepoint. I know it’s a bit outdated, so I’m adapting as I go along.

I’ve gotten to a place where I’m in my rails console, ready to start creating/saving to my database, and when I create a class, then type story.save, I get this error:

1.9.3p194 :007 > story.save
   (0.1ms)  begin transaction
  SQL (0.5ms)  INSERT INTO "stories" ("link", "name") VALUES (?, ?)  [["link", nil], ["name", nil]]
SQLite3::ConstraintException: constraint failed: INSERT INTO "stories" ("link", "name") VALUES (?, ?)
   (0.1ms)  rollback transaction
ActiveRecord::StatementInvalid: SQLite3::ConstraintException: constraint failed: INSERT INTO "stories" ("link", "name") VALUES (?, ?)
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/statement.rb:108:in `step'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/statement.rb:108:in `block in each'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/statement.rb:107:in `loop'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/statement.rb:107:in `each'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/sqlite_adapter.rb:263:in `to_a'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/sqlite_adapter.rb:263:in `block in exec_query'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/sqlite_adapter.rb:242:in `exec_query'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/relation.rb:66:in `insert'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/persistence.rb:363:in `create'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/timestamp.rb:57:in `create'
... 14 levels...
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/validations.rb:50:in `save'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/attribute_methods/dirty.rb:22:in `save'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:208:in `transaction'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:241:in `block in save'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/transactions.rb:240:in `save'
    from (irb):7
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
    from /Users/ideogram/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'1.9.3p194 :008 > 

I have no idea what this means. Any ideas? Help is much appreciated. 🙂

I’m running on a Macbook Pro OSX Lion 10.7.3, Ruby 1.9.3-194, Rails 3.2.3. Have installed homebrew, rvm, and then several packages including readlines, sqlite3, and git.

THANK YOU!

Addendum: here is my schema:

ActiveRecord::Schema.define(:version => 0) do

  create_table "stories", :force => true do |t|
    t.string "name"
    t.string "link"
  end

  add_index "stories", ["id"], :name => "sqlite_autoindex_stories_1", :unique => true

end

This is the sqlite command I used to create my table:

CREATE TABLE `stories` (
  `id` int(11) NOT NULL,
  `name` varchar(255) default NULL,
  `link` varchar(255) default NULL,
  PRIMARY KEY (`id`)
);
  • 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-06-03T14:58:31+00:00Added an answer on June 3, 2026 at 2:58 pm

    Thank you all very much for helping me out.

    Between your comments, I figured out the issue. The issue was in my database — it wasn’t created correctly so once I had deleted the original file and then recompiled the file again (making sure all of my commas were in the correct place) then it finally worked!

    I appreciate all your help, so thank you again. I learned quite a bit from your answers. 🙂

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.