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

  • Home
  • SEARCH
  • 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 6230315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:43:31+00:00 2026-05-24T09:43:31+00:00

Weird null error. I have a /lib/task rake script that refuses to set a

  • 0

Weird null error.

I have a /lib/task rake script that refuses to set a string value, when I run it rake reports this output/error:

Purchase

Purchase

PGError: ERROR: null value in column “type” violates not-null constraint
: INSERT INTO “account_logs” (“sum”, “type”, “usertype”, “transaction_id”, “commited”, “user_id”, “created_at”, “updated_at”)
VALUES (168.0, NULL, ‘Public’, 452921, ‘t’, 10146
, ‘2011-07-29 09:57:11.514472’, ‘2011-08-02 15:33:38.479838′) RETURNING “id”
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connect
ion_adapters/abstract_adapter.rb:207:in `rescue in log’

Which is very very strange since I actually set value which clearly is not NULL. How come???

My code is this:

  m_sum = Float(rand_int(1,500))
  m_type = "Purchase"

  puts m_type

  m_user_info = UserInfo.order("RANDOM()").first
  m_usertype = m_user_info.usertype
  m_transactionid=gid
  m_commited=true
  m_user_id=rand_int(1,User.count)
  m_created_at=rand_time(1.week.ago,Time.now)
  m_updated_at=Time.now

  if m_type.nil?
    puts "What the f"
  end
  puts m_type

  AccountLog.create(
    :sum               => m_sum,
    :type              => m_type,
    :usertype          => m_usertype,
    :game              => m_game,
    :transactionid     => m_transactionid,
    :commited          => m_commited,
    :user_id           => m_user_id,
    :created_at        => m_created_at,
    :updated_at        => m_updated_at
  )

#part of schema.rb
create_table "accountlogs", :force => true do |t|
  t.decimal  "sum",               :precision => 15, :scale => 10, :null => false
  t.string   "type",              :limit => 30, :null => false
  t.string   "usertype",          :limit => 30, :null => false
  t.integer  "transactionid",     :limit => 8,  :null => false
  t.boolean  "commited",                        :null => false
  t.integer  "user_id",           :limit => 8,  :null => false
  t.datetime "created_at"
  t.datetime "updated_at"
end

#Model

class AccountLog < ActiveRecord::Base
  belongs_to :user
end
  • 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-24T09:43:32+00:00Added an answer on May 24, 2026 at 9:43 am

    type appears to be a reserved, although deprecated, keyword in ruby.

    You probably want to rename your attribute to something else.

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

Sidebar

Related Questions

My weird monitor's native resolution isn't recognized by Windows, so I have to set
For some strange reason I get a weird error. I have an element (which
I keep getting a Null Object Refrence Error, but can't tell why. I have
Hello i have this foreach loop that gives weird result , it displays only
I have selected the database but for some weird reason it still says that
I have a weird error I'm trying to debug with no luck. I have
I'm having a weird error that happens under weird circumstances. The list of skill
I have 2 classes that reference each other. It's a weird situation that our
Due to a weird request, I can't put null in a database if there
Weird behavior when mixing loading of assemblies using Assembly.LoadFrom and Assembly.Load : I have

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.