search for: autoincrement

Displaying 20 results from an estimated 57 matches for "autoincrement".

Did you mean: auto_increment
2008 Jan 14
1
How do I add autoincrement?
Hello, I am attempting to learn Ruby on Rails. I''m using Instant Rails 2.0 on a Windows computer. I really want the id number to autoincrement, but I am not sure how to do that. The script that''s generated after the scaffold is listed below. Any help is appreciated. class CreateMenuitems < ActiveRecord::Migration def self.up create_table :menuitems do |t| t.integer :id t.string :category t.text :cate...
2008 May 22
4
how to find out autoincrement id ?
Hi I need to push newly created item id to file. (ie. its autoincrement value) I tried this on controller but it wont work, it cant find id value for the newly created item. def create @imitem = Imitem.new(params[:imitem]) system "echo \"@imitem.id\" > /tmp/myid" any help ? --~--~---------~--~----~------------~-------~--~----~ You recei...
2006 Jul 21
3
Migration and Mysql row ID
...and apparently Agile 2 says not to do this, but to use a DBA defined other identifier, and to leave the database assigned id attribute to the database, and not to use it for foreign keys. The first method seemed to make sense to me, however using migrations i''m finding that mysql 5 is autoincrementing the data each migration. So, if i add a single object/row of test data to a table in a migration, the first time i perform the migration the row is assigned id=1. If i then revert, and then reperform this migration, even though there is still only one row of data the second time, the item no...
2006 Feb 17
7
Create and then show
I am attempting to redirect to the show method after creating a new object. So, for example, once a new post is created the user is presented with the new post in a show view. The problem is I can''t get the correct <at> post.id to send to the show method. Rails always returns 0 for this value. Here''s what I have so far: class ContentController < ApplicationController
2006 Nov 04
0
any recommendations for handling a non autoincrement primary key
Hey everyone, I''m working on an application that has a table with a nice natural primary key. Outside of the rails world it would be *the* primary key. I would prefer to use this natural primary key and define associations that use it. I''ve done so but the problem is that my form for entering a record in this table is currently failing. I''ve used
2009 Sep 07
11
autoincrement for non-id column
There is a table: execute (<<-SQL) CREATE TABLE "tasks" ( "id" serial primary key, "number" serial, "version" integer DEFAULT 0 NOT NULL, "latest_version" boolean DEFAULT ''t'' NOT NULL, "hidden" boolean DEFAULT ''f'' NOT NULL, "type" character varying (1) NOT
2007 Sep 23
4
Story Runner, autoincrementing
I''ve written a story and I run into a snag. I''ve written the create_forum method and told it to set the id to 1 but when it creates the forum the id is autoincremented. My forums table is empty but the id keeps incrementing the newest record on creation. When I run the story it comes out as something like 59 which fails my story because I''m asking it to look at /forums/1 I thought of using my named routes instead of specifying the path as a string. Th...
2005 Dec 26
3
data insertion in multiple tables
I have two tables like: Table A: id (autoincrement) name Table B id id_of_A desc I want to add a record to table A and based on the id of A, I want to add a record to table B. I don''t think there is any SQL command that support this (at least in MySQL 4.1, so I use LAST_INSERT_ID()). (Is there any other way? or MySQL 5 su...
2007 Oct 16
2
Primary Keys enforcement vanishes in test database
I use this naming convention for primary keys: ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore I generate the MySQL test database: rake db:test:prepare, and although the column is there there is no primary key enforcement/index and no autoincrement (so activerecord saves fail). Is this a bug? What is the best workaround? Alan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails...
2005 Mar 07
3
exclude an attribute from save
Hi, I''ve used .save to save the attributes, but on my table there is an autoincrementing id (not the primary key) that doesn''t need to be inserted... but save try to INSERT it anyway... is there a way to avoid save from acting this way or to whisper him to be more polite this time? ;) Thanks, Enrico -- "The only thing necessary for the triumph of evil is for good men...
2014 Oct 30
3
Display graphic from filename broken?
...bler to C. I already discovered one bug in core/include/graphics.h (and core/graphics.c): the pointer VGAFilePtr is of type uint16_t*, but should be plain char*. This bug causes the file name to be assembled incorrectly in com32/elflink/ldlinux/msg.c (msg_filename(), line 160): there the pointer is autoincremented, and if it is a uint16_t*, then it will autoincrement by two bytes. Therefore there will be a null char every second byte, which makes everybody think the file name has only one single character. After fixing this, the file name is assembled correctly, and msg_viewimage() seems to open the file...
2006 Jun 09
3
sqlSave() and rownames=TRUE makes my Rgui crash
...2 2 4 6 ### But this makes Rgui crash and close chan <- odbcConnect("MySQL51", uid="root", pwd="xxx") sqlSave(chan, dframe, tablename="example", rownames = FALSE, append=T) close(chan) ### With rownames = T and safer=F, it works, but I loose the autoincrementing PK in MySQL chan <- odbcConnect("MySQL51", uid="root", pwd="momie") #default database=fbn sqlSave(chan, dframe, tablename="example", rownames = T, addPK=T,append=T,safer=F) close(chan) Any idea? I'm on win2K, MySQL version 5.0.21-community-nt &gt...
2006 Feb 24
9
Growing beyond unsigned integer for the id field
...are my options, I have looked at the GUID plugin that lets you use a 32 char GUID, but I still want the id''s to be sequential, and (I think) that the overhead of searching a varchar field will be too big for such a large number of records. It does not appear you can use a double as an autoincrement field in MySQL. Maybe because it is a float? So that can not be used. Im guessing there is some sort of pattern for this problem. My first thought was to create a second id field and increment that every time the first id field rolls over to zero. To do this I would need to override the get/se...
2006 May 13
1
Rake clone bug?
...rnal_pupil_set_id | int(11) | YES | | NULL | | | setlink_end_date | int(11) | YES | | NULL | | | setlink_start_date | int(11) | | | 0 | | +-----------------------+---------+------+-----+---------+-------+ which is missing the primary key and autoincrement for link_id, and has link_id as int(20) which doesn''t make sense! Still the same problem when I pare down my setlinks.yml to link1: link_id: 1 pupil_id: 1 pupil_set_id: 1 setlink_end_date: NULL setlink_start_date: 1 Is it me, or is there a bug here in the way rake clones the...
2007 Sep 11
3
ActiveRecord, blocking or async, logging, syslog/udp
...a very slow machine. Let''s further say that my app has an action that leads to a very simple insert into the "impressions" table of the db, a la "INSERT INTO impressions(docid) VALUES($docid);" - and let''s say the db automatically adds created_at as now() and autoincrements primary key. Will RoR/AR block on this insert? If so is there a way to make it non-blocking (asynchronous)? Alternatively, let''s say I wanted to log such impressions on a remote log server using UDP and syslog - any guidance on doing that? (Not all logging mind you, but just this spec...
2008 Apr 08
1
Help with primary_key_prefix_type
...ty_name drop_table :entities end end When I run these rake tasks: rake db:drop rake migrate Then I see this: # sqlite3 db/development.sqlite3 SQLite version 3.3.6 Enter ".help" for instructions sqlite> .schema entities CREATE TABLE entities ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "entity_name" varchar(40) NOT NULL, "entity_legal_name" varchar(120) NOT NULL, "entity_legal_form" varchar(4) NOT NULL, "created_at" datetime DEFAULT NULL, "updated_at" datetime DEFAULT NULL); But I expected to see this: CREATE TABLE en...
2006 Jun 26
8
id of last element in a table
Hi, I would like to figure out how to determine what the id of the last element in a table is. Is there an equivalent to the Table.find() method which will tell me the number of elements in a table? also, maybe more importantly, where are the available methods on tables documented? What i am trying to do is to increment the id and work through a table and check whether the id i am currently
2007 Sep 18
2
Auto-incrementing column
Ok, I have an table column that needs to auto-increment, but isn''t the primary key (although I guess it could be). The format for the column is "SR001234" and it needs to autoincrement like so: SR001234 SR001235 SR001236 ... SR999999 How can I do this? I know Ruby has some pretty nice constructs for doing things like this, but I just don''t quite see how to put them into Rails yet. --~--~---------~--~----~------------~-------~--~----~ You received this message because...
2006 Sep 26
1
Error while generating scaffold
...n "Agile Web Application Development with Rails" first edition on page: 57. Just to give some context to what I am doing, I just created the depot application, configured my database (sqlite) entered the products table with the following SQL: create table products( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, title varchar(100) NOT NULL, description text NOT NULL, image_url varchar(200) NOT NULL, price money(10,2) NOT NULL ); My database yml contains: test: adapter: sqlite dbfile: db/test.db production: adapter: sqlite dbfile: db/prod.db development: adapter: sqlite dbfile: db/dev...
2006 Jan 04
4
many to many link table compound primary key explosion
Hi, I have a many-to-many relationship between two tables, questions and answers. My MySQL schema for the link table creates a primary key from the two fields to prevent duplicate records. When I add the same answer to the same question more than once, rails attempts to create a duplicate record and explodes with a MySQL error: MysqlError: Duplicate entry ''3-3'' for key 1: