Displaying 20 results from an estimated 200 matches similar to: "Help with primary_key_prefix_type"
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
2005 Jan 28
16
primary_key_prefix_type, support for non-integer primary keys
Hello!
I''m just starting out with Rails--and Ruby itself for that matter--and
have a couple of questions regarding primary_key_prefix_type and
non-integer primary keys.
I see in the ActiveRecord documentation [1] that by default the primary
key of a table "foo" is expected to be "id", though
primary_key_prefix_type this can be changed to :table_name or
2008 Mar 08
9
Validation error handling on related models
I have 2 models, entity and client. Entity has_one client and client
belongs_to entity.
Entity has attributes name and legal_name. Entity also has an unique
index on (lower(name)). The pKey for both is the conventional Rails id.
Client has a fKey constraint on entity_id and is indexed in entity_id.
In controllers/clients_controller.rb I have:
# GET /clients/new
# GET /clients/new.xml
2006 Apr 20
5
Integrating with Legacy Databases
This seems like it must have been asked before - I really _did_ try to
find it in the archives, so my apologies if it''s already out there.
Utilizing ActiveRecord, I would like to specify a prefix for the
column names in my table. For example, in ''Recipe 16 Integrating with
Legacy Databases'' (Rails Recipes, from PragProg, by Fowler) they deal
with integration with a
2009 Mar 09
10
Cucumber - RSpec matcher
I must be missing something obvious here but I cannot seem to see it.
I have this step definition:
When /entity named "(.*)" has a legal name "(.*)"/ do |name, legal|
myentity = Entity.find_by_entity_common_name!(name.hll_keycase)
myentity.entity_legal_name.should equal legal.hll_keycase
end
Which fails with this:
And the entity named "Myuser" has a legal
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
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 support any special SQL command?)
But I need
2012 Mar 02
0
ConnectionNotEstablished when using connection on AR::Base abstract subclass
I''m using AR outside of Rails and calling establish_connection on an
ActiveRecord::Base abstract_class subclass (to protect my connection
in case anyone else is using AR). It was working just fine with AR
3.0.9, but I recently attempted to upgrade to AR 3.2.2. Now, when I
hit a "nested" query from a has_many, I get a
ActiveRecord::ConnectionNotEstablished. If I call
2006 May 13
1
Rake clone bug?
Hi. I''m having a problem with my testing. The following table in my
development database (MySQL 4.1.12, InnoDB):
+-----------------------+------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default |
Extra |
+-----------------------+------------------------+------+-----+---------+----------------+
|
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
2006 Sep 26
1
Error while generating scaffold
Hello,
When I run the command:
"ruby script/generate scaffold Product Admin"
I receive the following error after the usual changed files info:
"Couldn''t find ''product'' generator"
The command is based on "Agile Web Application Development with Rails"
first edition on page: 57. Just to give some context to what I am
doing, I just created
2006 Feb 24
9
Growing beyond unsigned integer for the id field
I am creating an app that will out grow an int(10) unsigned for the id
field, ie. 4,294,967,295 records.
What 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
2014 Oct 30
3
Display graphic from filename broken?
Hi,
the display of LSS16 files from a DISPLAY file (as documented in
http://www.syslinux.org/wiki/index.php/SYSLINUX#Display_graphic_from_filename:)
seems heavily broken since syslinux has been converted from assembler 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
2005 Aug 06
2
Problem with 0.13.1 ActiveRecordStore with PG 8.0.3.
Hi,
I put the following in my environment.rb file:
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update
(:database_manager => CGI::Session::ActiveRecordStore)
Runnning WEBrick via "script/server" and trying to load any page
served by a controller results in an error like the following:
#<ActiveRecord::StatementInvalid: ERROR: null value in column "id"
2005 Dec 27
4
Migrations & Unit Testing: Possible Bug in Rails?
I recently started using migrations to create the schema of a Rails
project I am working on. The database I am using for this project is
MySQL. The initial migration creates the table and also includes a
number of execute statements (to do some things like setting primary
keys, autoincrement on some columns and other messy voodoo).
Running "rake migrate" creates the database with no
2006 Mar 31
0
acts_as_taggable doesn''t work with uniqueidentifier
Hi all,
it seems like the acts_as_taggable is not capable to work with
uniqueidentifier as the datatype of the primary key in the tags table.
however, it works like a charm with int and autoincrement. could that be
fixed any time soon?
--
Posted via http://www.ruby-forum.com/.
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
2014 Oct 30
0
Display graphic from filename broken?
> Hi,
>
> the display of LSS16 files from a DISPLAY file (as documented in
> http://www.syslinux.org/wiki/index.php/SYSLINUX#Display_graphic_from_filename:)
> seems heavily broken since syslinux has been converted from assembler 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
2006 Jun 06
4
Troubleshooting "Lost connection to MySQL server.."
Hello all,
Though I''ve read all I could about the "Lost connection to MySQL
server during query: SHOW FIELDS FROM ...", I''m still unable to use RoR.
I''m on Linux Mandriva 2006 / MySQL-4.1.12 / ruby-1.8.2
- The userid/password have access to the database and the table (it''s
the root user on MySQL)
- I''m on a nonstandard socket/port, but