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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:07:51+00:00 2026-05-23T06:07:51+00:00

In my model I have class Alias include DataMapper::Resource belongs_to :user property :id, String,

  • 0

In my model I have

    class Alias
  include DataMapper::Resource


  belongs_to :user


  property :id, String, :key => true, :required => true, :unique => true

  validates_format_of :id, :with => /[0-9a-z\-]/i

end

In my controller:

def new
   @new_alias = @owner.aliases.new()
end
    def create 
         @owner = current_user
         @alias = @owner.aliases.create(params[:alias])
end

And in my view

<%= form_for @new_alias, :url => {:controller => "aliases", :action=>"create"} do |f| %> 
    <%= f.text_field :id, :placeholder => "Account name" %></br>
    <%= f.submit :value => "Create" %>
 <% end %>

For me it looks preatty normal, but when I’m trying to save new alias, it results with with:

ERROR:  null value in column "alias_id" violates not-null constraint

Processing by AliasesController#create
as HTML Parameters: {“utf8″=>”✓”,
“authenticity_token”=>”/token=”,
“alias”=>{“id”=>”IDNAME”},
“commit”=>”Create”} ~ SQL (0.632ms)
SELECT “id”, “encrypted_password”,
“remember_created_at”,
“reset_password_token”,
“reset_password_sent_at”,
“failed_attempts”, “unlock_token”,
“locked_at”, “sign_in_count”,
“current_sign_in_at”,
“last_sign_in_at”,
“current_sign_in_ip”,
“last_sign_in_ip”, “username”,
“email”, “name”, “country” FROM
“users” WHERE “id” IN (2) LIMIT 1 ~
SQL (0.491ms) SELECT “id” FROM
“aliases” WHERE “id” = ‘IDNAME’ ORDER
BY “id” LIMIT 1 Completed in 11ms ~
SQL (0.531ms) INSERT INTO “aliases”
(“id”, “user_id”) VALUES (‘IDNAME’, 2)
~ ERROR: null value in column
“alias_id” violates not-null
constraint (code: 33575106, sql
state: 23502, query: INSERT INTO
“aliases” (“id”, “user_id”) VALUES
(‘IDNAME’, 2), uri:
postgres:name@localhost:5432postgres?adapter=postgres&host=localhost&port=5432&username=name&password=pass&database=postgres&path=postgres&schema_search_path=public&encoding=utf8&template=template0)

DataObjects::IntegrityError (ERROR:
null value in column “alias_id”
violates not-null constraint ):
app/controllers/aliases_controller.rb:5:in
`create’

What could be the problem? I’m using rails3, postgres and datamapper.

  • 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-23T06:07:51+00:00Added an answer on May 23, 2026 at 6:07 am

    Not familiar with rails internals, but your column’s definition must be so that it allow null values.

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

Sidebar

Related Questions

In my model I have : class Alias(MyBaseModel): remote_image = models.URLField( max_length=500, null=True, help_text='''
I have a model as follows: class Property < ActiveRecord::Base has_and_belongs_to_many :property_values end What
I have class Cab(models.Model): name = models.CharField( max_length=20 ) descr = models.CharField( max_length=2000 )
In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes
I have a class in my domain model called JobPlan this class is stored
I have a class that has a Generic type G In my class model
Let's say I have a model like this class Foo(db.Model): id = db.StringProperty() bar
I'm used to the Java model where you can have one public class per
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage

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.