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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:52:26+00:00 2026-06-18T13:52:26+00:00

I’m trying to learn Ruby on Rails and have encountered a problem I need

  • 0

I’m trying to learn Ruby on Rails and have encountered a problem I need help with. What I’m trying to do is to create a “project manager” with a form, but whne I’m filled in the form and clicks submit the following error is shown:

ActiveRecord::StatementInvalid in ProjectsController#create

SQLite3::ConstraintException: constraint failed: INSERT INTO "projects" ("created_at", "description", "end_date", "start_date", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?, ?)

Rails.root: /Applications/XAMPP/xamppfiles/htdocs/IDV450-labb1

Application Trace | Framework Trace | Full Trace
app/controllers/projects_controller.rb:14:in `create'

The project controller:

1.   class ProjectsController < ApplicationController
2.
3.      def index
4.        @projects = Project.all
5.      end
6.
7.      def new
8.        @project = Project.new
9.      end
10.
11.     def create
12.       @project = Project.new(params[:project].merge(:user_id => current_user.id))
13.
14.       if @project.save
15.         redirect_to projects_path
16.       else
17.         render :action => "new"
18.       end
19.     end
20.   end

The project model:

class Project < ActiveRecord::Base
    has_and_belongs_to_many :users
    belongs_to :ticket

    attr_accessible :user_id, :title, :description, :start_date, :end_date
end

The view for new project:

<%= form_for @project do |f| %>
    <div class="text_field">
        <%= f.label :title%>
        <%= f.text_field :title%>
    </div>
    <div class="text_field">
        <%= f.label :description%>
        <%= f.text_field :description%>
    </div>
    <div class="dropdown">
        <%= f.label :start_date%>
        <%= date_select :start_date, :startdate %>
    </div>
    <div class="dropdown">
        <%= f.label :end_date%>
        <%= date_select :end_date, :enddate %>
    </div>
    <div class="select">
        <%= f.label :title%>
    </div>
    <div class="submit">
        <%= f.submit "Save" %>
    </div>
<% end %>

The db models:

Project:
    - id: int
    - user_id: int
    - title: varchar(50)
    - description: varchar(500)
    - start_date: date
    - end_date: date
    - created_at: datetime
    - updated_at: datetime

Request parameters that are sent:

{"utf8"=>"✓",
 "authenticity_token"=>"CrFUjpsRCEWRprSmKtOk4nBxsxrwaII1WKLDWMQWuUI=",
 "project"=>{"title"=>"Foo project",
 "description"=>"A little description"},
 "start_date"=>{"start_date(1i)"=>"2013",
 "start_date(2i)"=>"2",
 "start_date(3i)"=>"7"},
 "end_date"=>{"end_date(1i)"=>"2014",
 "end_date(2i)"=>"3",
 "end_date(3i)"=>"12"},
 "commit"=>"Spara"}

It really doesn’t say what the problem is, but it happens on line 14 when it tries to save to the db. If I create a project in seed it works!

  • 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-18T13:52:27+00:00Added an answer on June 18, 2026 at 1:52 pm

    Maybe you have some validation on project model or in projects table(which can be seen in schema.rb file) which is failing

    Or You can try incrementally checking creating project model by removing all attributes from model and trying to create the object

    Try printing the @project object and see what values its using for its creation

    you should use save! rather than save

    Hope it helps..

    🙂

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I need to clean up various Word 'smart' characters in user input, including but

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.