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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:54:52+00:00 2026-06-11T20:54:52+00:00

controller/makenew.rb class MakeController < Controller map ‘/makenew’ #require ‘model/debate’ def debate if request.post? #this

  • 0

controller/makenew.rb

class MakeController < Controller

  map '/makenew'
  #require 'model/debate'

  def debate
    if request.post? #this line is potentially dangerous!
      #---> 1/3 fetch postdata
      data = request.subset(:question, :type, :category, :assertion)
      data['user_id'] = user.id #id = request.params['id']
      #---> 2/3 check permissions
      if user.points < 40
        flash[:error] = 'You don\'t have enough points to make a debate.'
        redirect_referrer
      else
        debate = Debate.new
      end
      #---> 3/3 modify database
      begin
        debate.save(data)
        flash[:success] = success
        flash[:form_data] = debate
        redirect 'debates'
      rescue => e
        Ramaze::Log.error(e)
        #flash[:form_errors]   = debate.errors
        #flash[:error] = data
        flash[:error] = e
        #flash[:error] = 'Failure whilst saving. Contact technical support!'
        redirect 'debates' #redirect_referrer
      end
     #| 
    end #closes posting conditional
  end #closes makesave 
end

The error I get is.

SQLite3::ConstraintException: debates.question may not be NULL

I have checked the postdata for data.question and it is not null.

What is going on?

  • 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-11T20:54:53+00:00Added an answer on June 11, 2026 at 8:54 pm

    You need to pass ‘data’ to #update. Thus:

    debate.save(data)
    

    is wrong, you have to do:

    debate.update(data)
    debate.save
    

    If you don’t do this, your debate object has no member assigned and thus its question member is nil, violating your DB constraints.

    See the differences between #save and #update here:

    • Update : http://sequel.rubyforge.org/rdoc/classes/Sequel/Model/InstanceMethods.html#method-i-update
    • Save : http://sequel.rubyforge.org/rdoc/classes/Sequel/Model/InstanceMethods.html#method-i-save

    In a nutshell: #save will save the current model instance to the database, while #update will change a bunch of instance attributes in one operation.

    But you have to remember that changing a model instance’s attributes DOES NOT write them to the database. You always have to call #save explicitly.

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

Sidebar

Related Questions

My Controller (User Controller) def reset_password @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil? if request.post? if
My Controller (User Controller) def reset_password @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil? if request.post? if
Controller ClientDocument. def upload_document ClientDocument.upload_client_document(params) end Model ClientDocument. Class method.. def self.upload_client_document(params) self.new :uploaded_data
Controller: class GalleriesController < ApplicationController def index @galleries = Gallery.all end end View: <%
Controller: class SessionsController < ApplicationController layout 'login' def create user = login(params[:username], params[:password]) if
Controller function delete_payment($payment_id) { $this->sale_lib->delete_payment($payment_id); $this->_reload(); } View <?php echo anchor(sales/delete_payment/$payment_id,'['.$this->lang->line('common_delete').']');?> It is possible
Controller: def test = Action { implicit request => import play.api.i18n._ val msg =
Controller Call user = User.authenticate(params[:session][:email], params[:session][:password]) Authenticate Method in user.rb class << self def
Controller code: class HelpController<ApplicationController def index @url = https://example.com/auth?user_id=1234&redirect_to=http://google.ru end end View code: <script>location.href='<%=@url%>';</script>
controller function def request_invite if !request.xhr? render_404 return end @invitation = Invite.new(params[:invite]) if @invitation.save

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.