Displaying 20 results from an estimated 4000 matches similar to: "any recommendations for handling a non autoincrement primary key"
2006 Jul 15
1
Relationship problem, newbie problem, need help!!
Hey all
I seem to be having some problems with my relationship between a few
tables...
If i then run the following query in mysql, i get the data i want. How
do i do this in rails relationships and models?
select * from shop_addresses
left join shops on shops.id = shop_addresses.shop_id
left join styles on styles.id = shops.style_id
where shop_uri = ''127.0.0.1''
Cheers!!
2002 Nov 09
1
[LLVMdev] Your $200 are waiting you
2006 Feb 28
0
ActiveRecord: Legacy primary keys
Hi,
I''m building a frontend for a legacy schema, with tables like this:
CREATE TABLE `types` (
`a_type_cd` varchar(6) NOT NULL default '''',
`a_type` varchar(30) NOT NULL default '''',
PRIMARY KEY (`a_type_cd`)
);
The primary key is specified by the user (not auto-generated), and needs
to be updateable. I create the following a base class to
2006 Nov 04
0
ActiveRecord, insert and not auto-incremented primary keys...
Hi,
After playing while with ActiveRecord, I''m surprised it isn''t easier to insert data into a table whose primary key is not auto-incremented by the database server.
The following code...
---------------------------------------
-- MySQL database "test"
---------------------------------------
CREATE TABLE gardens
(
code integer NOT NULL,
name
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|
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 received this message because you
2007 Sep 04
2
Use of uniqueidentifer type for primary key?
I''m working on a legacy SQL db. It is distributed, to they are using
the uniqueidentifier type for the primary key.
At first, at least, I won''t be updating records, but I''m seeing a lot
of negativity about using anything other than incrementing integers
for the pk--which are obviously inadequate for this environment.
It is enough to use set_primary_key? Do I need
2007 Mar 01
1
PostgreSQL primary (sequence) key issue
Hi,
I have a sequence set up on one of my tables called seq_user_mytable. I
tried the following with no joy:
set_primary_key "user_id", :sequence => "seq_user_mytable" and:
ActiveRecord::Base.seq_user_mytable
again with no joy. How do I implement a sequence in Rails/ActiveRecord?
--
Regards
Andrew
--~--~---------~--~----~------------~-------~--~----~
You received this
2004 Aug 07
0
Can You Last 36 Hours E|R|E|C|T|I|O|N? zas
User ID: 2 bushel
Date: Sat, 07 Aug 2004 02:29:50 -0700
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="--197563323375802931"
----197563323375802931
Content-Type: text/html;
Content-Transfer-Encoding: 7Bit
Syslinux
<html>
<body text=black bgcolor=white link=blue alink=blue vlink=blue>
<center>
<b><font color=blue>Wanted to try Cialis
2006 Jun 14
0
Custom Primary Key, Using Primary Key in Form gives "before_type_cast" error?
Hi guys,
I''ve got a problem here which i need help from the pro''s in this mailing list
I have a legacy app where the User table has a custom structure where
"User_id" (username) is the primary key as well as the username used
to log in
User.rb (model)
class User < ActiveRecord::Base
set_table_name "cmf901"
set_primary_key "user_id"
end
2006 Jun 13
2
Custom Primary Key, Using Primary Key in Form "gives before_type_cast" error?
Hi guys,
I''ve got a problem here which i need help from the pro''s in this mailing list
I have a legacy app where the User table has a custom structure where
"User_id" (username) is the primary key as well as the username used
to log in
User.rb (model)
class User < ActiveRecord::Base
set_table_name "cmf901"
set_primary_key "user_id"
end
2010 Aug 19
1
Composite primary keys and :joins=>
I have a legacy db with the following simplified structure:
Table-A:
type_key, code_key, name, ... # PKs are type_key and code_key,
there is no id col and I cannot alter this db
Table-B: # each row has only the code as a foreign_key, the type_key
is hard-coded to "FOOKEY"
an_id, code, ...
Models:
class TableB < AR::Base
set_table_name ''table_b''
2006 May 12
0
Using primary key that is not named "id"
Hi
I am using a legacy database that the primary key is named "ProductID"
and its type is SERIAL (or INT NOT NULL auto_increment).
set_primary_key "ProductID", is added to the Product class
Then I used >ruby script/generate scaffold Product Admin
to generate my controllers. When I try to insert a new product in the
products table, it gave me this error
RuntimeError:
2009 May 01
1
how to disable auto-increment in primary key.
How can i disable the auto-increment for a primary key data type. The
purpose of using primary_key data type is using different name for
primary key. But we still want to use all the properties of "id"
except for auto increment part.
I had my migration as following
#=============MIGRATION
def self.up
create_table :pk2s , :id=> false do |t|
t.primary_key :uid
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
2006 Jun 09
2
Support for clustered primary key in rails?
Hi, I need to support a legacy database that mostly uses clustered
primary keys (i.e. every primary key consiststs of multiple fields not
just a single one. E.g. if I have tables A,B and C and C depends on
tables A and B, then C''s primary key will consist of 3 or more fields-
the foreign key fields pointing to A and B and a field or fields from C
that will make C unique- in
2005 Dec 20
7
wrong id for activerecord object when using :joins in mysql
I''m using a find with a :joins clause, like this:
:joins => "JOIN table_b ON table_b.id=table_b_id"
The records returned are used in a scaffold generated list page. The edit,
show, and destroy links are getting the wrong id. They are getting the id of
the table b record.
When I run the query using mysql, I see that the query returns *2* id
columns, the id of the main
2007 Apr 17
0
set_primary_key issue
Hi:
I am new to the ruby and rails. What I am tried to do is to create a
scaffold based on an existing table in a MS SQL Server database.
Before I used the set_primary_key method, edit and show does not work
in the generated code. Rails displayed the list of the records ok, but
can not determine the id for each record. Create a new record does
work properly, however.
After I used the
2005 Dec 26
16
How to create application with single table with primary key
I''m trying without any succes to create application in which I have
one keyed table. The table structure is:
CREATE TABLE employees (
pin INTEGER PRIMARY KEY,
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL
);
Whenever I enter new record, I need the the filed pin is also filled
by user. Whenever a user edit the table, there should be option to
edit or not edit the
2006 Feb 22
3
is there really a restart task in switchtower? How do you invoke it?
I just created a new rails project "test".
I then did "switchtower --apply-to ~/user/test test"
I then moved into test and tried "rake restart" and got:
kfelkins@lurch:~/user/test$ rake restart
(in /home/kfelkins/user/test)
rake aborted!
Don''t know how to build task ''restart''
I see restart in deploy. Can restart be invoked from the