Displaying 20 results from an estimated 200000 matches similar to: "add_primary_key"
2006 Mar 26
1
add_primary_key Re: #3735
Hey guys,
With the addition of has_many :through, a number of people will
probably want to add primary keys to their current ''rich association''
tables. Currently we don''t have an add_primary_key. We have a ticket
for it[1], and I''ve attached a simple patch[2].
It works fine for mysql and postgres (8) and Rick is looking at sqlite.
Could those of you who use
2007 Feb 07
5
Problems Generating Scaffolding
I am having trouble generating some of my scaffolding. I''m trying to
use PostgreSQL as my back-end. Some of my scaffolding generates with
no problem but for other parts I get this:
Before updating scaffolding from new DB schema, try creating a table
for your model
The tables do exist. At least I can see them from psql.
Here is the SQL I''m using to create my tables:
CREATE
2007 Nov 17
0
Postgres sequencer and rails
Hi All,
I''m wrestle with postgres database and rails.
Finally it''s working but i need some explanation :
So :
I have a sequencer :
CREATE SEQUENCE players_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 4
CACHE 1;
ALTER TABLE players_id_seq OWNER TO squash;
Table :
CREATE TABLE players
(
id bigserial NOT NULL,
firstname character varying,
2008 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message.
I am new to RoR, and ruby too, but i am quite excited about it.
I am developing a RoR project and with active record associations in
the following
manner
# Tables (all tables have only one record)
CREATE TABLE `webcars_development`.`cars` (
`id` int(11) NOT NULL auto_increment,
`model_id` int(11) NOT NULL default ''0'',
2008 Jul 01
6
validates_associated & foreign keys
Hi,
I''m struggling to get the validates_associated to work as I think it
should be.
I''m using:
JRuby 1.1
rails-2.0.2
activerecord-2.0.2
activerecord-jdbc-adapter-0.8.2
My tables in MySQL:
CREATE TABLE area_codes (
id INT UNSIGNED auto_increment primary key
...
);
CREATE TABLE markets (
id INT UNSIGNED auto_increment primary key,
...
);
CREATE TABLE
2008 Mar 29
0
message board help
Im trying to do the message board tutorial here but I have rain into a
problem
I get this error message
SQLite3::SQLException: table posts already exists: CREATE TABLE posts
("id" INTE
GER PRIMARY KEY AUTOINCREMENT NOT NULL, "body" text DEFAULT NULL,
"created_at" d
atetime NOT NULL, "name" varchar(100) DEFAULT NULL, "discussion_id"
integer NOT
2006 Aug 23
5
validation, concurrency, and transactions
Hi,
Something has been bothering me about model validation: how do I know that
the database has not changed in between when I validate my model''s data, and
when it actually gets saved to the database? As a simple example, say I have
a User model like:
class User
validates_uniqueness_of :username
end
When this gets saved to the database, the validation code checks that there is
2006 Dec 14
1
create and destroy fixture manually in method
Hi,
My test case has two fixtures and eight methods. But one of the eight
methods need one more fixture. How do I solve this? Okay, I put the
additional fixture in common place so every method has additional access
to the additional fixture. The problem is the additional fixture depend
on that two fixtures (foreign key). When I run the test, it complains
something like this:
2008 Mar 21
5
foreign key question
Hi-
Say I have a db with following schema:
MyTable:
Id, name, user_id, date
User:
id, name, description
I know that I want to add "belongs_to" in my "user" model but how can
I enforce a proper constraint on the user_id in "MyTable"? Is this
done using a has_one in the "MyTable" model?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You
2006 Dec 08
19
HABTM join table quirk
I''ve been bringing up a good basica framework for applications at work.
To give decent security I''ve been implementing the Rails Recipie for
Authorization of function calls modeled on the book''s implementation.
(Changes for our environment were added..but are minor.)
Since I initially let Rails create the join table between two data
tables with a HABTM relationship....I
2008 Apr 09
6
Using Ruby on Rails with existing database
Hi, I''m a complete newbie to this, I''m afraid. Apologies if this has
been answered elsewhere, but I''ve had a look, and can''t find the
answers I''m looking for, especially for using Rails 2.0.
We have an existing database which we would need to connect Rails to,
and the database structure is not what Rails would seem to expect.
Firstly, tables are not
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
2008 Apr 04
1
rails unit testing removes foreign key constraints in test database?
I''ve noticed that when testing is finished that at some point Rails
has removed the foreign key constraints from my test database. Does
anyone know where this foreign key constraint deletion occurs in the
source code. I''d like to turn it off.
Thanks,
Peter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
2007 Aug 23
6
Saving ActiveRecord in PostgreSQL without id
I have a small table that is used to temporarily queue requests, as such
it does not have an id field (or any other primary key), because it
doesn''t make sense to have one.
When I created an ActiveRecord class and tried to save it, I get:
ActiveRecord::StatementInvalid: PGError: ERROR: relation
"temp_requests_id_seq" does not exist
It keeps looking for the id to auto
2008 Oct 08
5
schema.dump chokes on RAW type
I haven''t seen anyone mention this yet.
The tail end of the migration process is a call to schema.dump. Our
primary keys are uuids and these choke schema.dump on both oracle and
postgres. The latter fails silently (skips three tables) while the
former complains about the RAW(16) in each of the three tables.
Anyone had a similar experience?
--
Posted via http://www.ruby-forum.com/.
2007 Sep 05
8
Hi..Guys new plugin again
Hi..
Guys new plugin again
Foreign Key Associations is a plugin that automatically creates
associations based on foreign-keys. The associations are created at
runtime-ie. as your ActiveRecord models are loaded-so they will always
be up-to-date.
For example, given a foreign-key from a customer_id column in an
orders table to an id column in a customers table, the plugin
creates:
2007 Jul 19
1
Storing order of sortable objects in RoR
I have two sortable lists that you can drag and drop to and from. Each
object in the lists have a position field in the object''s table. I
want to be able to update the position in the database automagically
once a user has sorted the list.
I can drag and drop just fine but I am not able to store the new
positions in the database.
I am trying to use Ajax.request in the onUpdate callback
2008 May 21
2
Scaffolding and ActiveRecord in Rails 2
Hi,
Is is possible to add this constraint: "null => false" and "limit => 45"
like below:
create_table :movie do |t|
t.string :name, :null => false, :limit => 45
end
...just by using this kind of scaffold command (on Rails 2)?
$ ruby script/generate scaffold Movie name:string
Thanks,
D.
--
Posted via http://www.ruby-forum.com/.
2008 Apr 30
4
Beginner mysql problem
I am new to rails and have come across a problem with a sample
application I was working on.
When trying to use rake migrate I got the error listed below.
my db file contains the following
class ContactDb < ActiveRecord::Migration
def self.up
create_table "people" do |t|
t.column "id", :integer
t.column "name",
2007 May 01
5
duplicate key violates unique constraint
I''ve run into an interesting issue. When setting up a table with data
from a file (I''m doing this in a block). I find that I can''t create
separate entries manually after the import. It complains about a
duplicate primary key. I''ve tried Schedule.id += 1 but id= either
isn''t defined or accessible in the class
Here is my code: