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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:20:43+00:00 2026-05-28T19:20:43+00:00

This is my webrick dump on create_note method call of note model Parameters: {utf8=>✓,

  • 0

This is my webrick dump on create_note method call of note model

Parameters: {"utf8"=>"✓", "authenticity_token"=>"T/F/oZaUYHz7G3HUjVKDs+Qjx+hrg6VqU4t1vr14ACc=", "note"=>{"notename"=>"Hello World 3", "notecontent"=>"3rd time hello world"}, "commit"=>"Create"}
   (0.2ms)  BEGIN
  SQL (0.3ms)  INSERT INTO `notes` (`created_at`, `notecontent`, `notename`, `updated_at`, `user_id`) VALUES ('2012-01-30 07:04:31', NULL, NULL, '2012-01-30 07:04:31', 1)
   (3.3ms)  COMMIT
   (0.1ms)  BEGIN
   (0.1ms)  COMMIT
  Rendered note/create.html.erb within layouts/application (2.5ms)
Completed 200 OK in 58ms (Views: 13.4ms | ActiveRecord: 5.8ms)

See that the insert coming with NULL values for notecontent and
notename.

My model file is

class Note < ActiveRecord::Base
        self.table_name = "notes"
        validates_length_of :notename, :within => 5..50, :message => "Notename 5-50 chars"
        validates_length_of :notecontent, :within => 5..50, :message => "Notecontent 5-50 chars"
        attr_protected :id
        belongs_to :user

        attr_accessor :notename, :notecontent, :created_at, :updated_at

        def self.get_notes_by_user(id)
                usernotes =  Note.find :all, :conditions => ["user_id = ?", id]
                return usernotes
        end


        def self.create_note(name, content, user)
                n = Note.create(:notename => name , :notecontent => content, :user_id => user)
                if n.save!
                        return true
                else
                        return false
                end
        end

        def self.update_note (id, content)
                n = Note.find :first, :conditions => ["id = ?", id]
                n.notecontent = content;
                n.updated_at = 0.hour.from_now
        end
end

My Controller file is

class NoteController < ApplicationController

        #before_filter :login_required
  def create
        if session[:user] == nil
                redirect_to :controller => "user", :action => "login"
        end
        if request.post?
                @nname = params[:note][:notename]
                @ncontent = params[:note][:notecontent]
                @uid = session[:user].getid
                @ins = params.inspect
                status = Note.create_note @nname, @ncontent, @uid
                if status == false
                        flash[:warning] = "Error While Creating Note"
                else
                        flash[:notice] =  "Note Successfully Created"
                end
        end
  end

  def delete
  end

  def show
  end

  def index
        if session[:user] == nil
                redirect_to :controller => "user", :action => "login"
        end
        user = session[:user]
        @uname = user.getname
        #nn = Note.new
        @user_notes =  Note.get_notes_by_user(user.getid)
  end
end

I have checked that the values are being populated for the arguments in the create_note method in the Note Model. but it seems somehow it is unable to map those values into the database query language. Please help.

My Migration file is

class AddUidToNotes < ActiveRecord::Migration
  def self.up
        add_column :notes, :user_id, :int
  end
end

class CreateNotes < ActiveRecord::Migration
  def self.up
    create_table :notes do |t|
        t.column :notename, :string
        t.column :notecontent, :string
      t.timestamps
    end
  end

  def self.down
    drop_table :notes
  end
end

DBCONSOLE

mysql> desc notes;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| notename    | varchar(255) | YES  |     | NULL    |                |
| notecontent | varchar(255) | YES  |     | NULL    |                |
| created_at  | datetime     | NO   |     | NULL    |                |
| updated_at  | datetime     | NO   |     | NULL    |                |
| user_id     | int(11)      | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
  • 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-28T19:20:45+00:00Added an answer on May 28, 2026 at 7:20 pm

    Don’t ever use attr_accessor with a database backed attribute. This will override the accessors ActiveRecord provides with a separate set of accessors that don’t write to the storage ActiveRecord uses.

    Not to be confused with attr_accessible which is part of the mass assignment protection system and absolutely fine to use

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

Sidebar

Related Questions

This error just started popping up all over our site. Permission denied to call
How can I get more information from an error like this? => Booting WEBrick
My error: Notice the undefined method '-@' . This is for a sort by.
I'm trying to block all non-localhost attempts to access a Webrick process. This is
Note: I've included all my console output as pastebin links to keep this question
I switched from WEBrick to Phussion Passenger following this guide: http://developer.apple.com/library/mac/#featuredarticles/PhusionRails/index.html . I used
Looking at the logs, my cedar app currently runs webrick. Obviously, this is not
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today

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.