Displaying 20 results from an estimated 2000 matches similar to: "x is not a number error??"
2008 Nov 14
3
migration with data
Hi
I am using postgres and have two migration files like
001_create_categories.rb as
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.column :name, :string, :limit=>80
end
end
def self.down
drop_table :categories
end
end
and 002_populate_categories.rb
class PopulateCategories < ActiveRecord::Migration
2006 Jul 14
3
postgres migration notices
When I run "rake" using a postgres 8.1 database, I get a bunch of these notices.
NOTICE: CREATE TABLE will create implicit sequence
"categories_id_seq" for serial column "categories.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"categories_pkey" for table "categories"
How can I avoid those? I take it I need to modify the
2006 Aug 16
14
Migrations: only one table per migration file?
Hi all
I have a new migration file created that adds some tables and fills one
with some data:
create_table :sound_styles do |t|
t.column :name, :string, :null => false
end
create_table :show_types do |t|
t.column :name, :string, :null => false
end
create_table :countries do |t|
t.column :name, :string, :null => false
end
ActionView::Helpers::FormOptionsHelper::COUNTRIES.each
2006 Feb 09
1
migration with PostgreSQL - function nextval does not exist
This might be a problem with postgresql, but I''m not sure. In a
migration I have renamed a table so I wanted to rename a sequencer as
well. It looks like:
execute "ALTER TABLE global_vacations_id_seq RENAME TO vacations_id_seq;"
execute "ALTER TABLE vacations ALTER COLUMN id SET DEFAULT
nextval(''vacations_id_seq''::regclass);"
But the process of
2010 Jul 21
1
asterisk realtime SIP configuration
Hi All,
I am trying to configure asterisk realtime. But i am unable to get the
extensions listed successfully when i type "sip show peers" in the asterisk
CLI . i am unable to see any failure logs when i do a reload
i can able to connect to the data source through "odbc show" in the
CLI, Any hep in this regard is highly appreciated. Following is the
configuration
2006 Jul 20
4
Help with Rails and postgres with sequence numbers (global?)
Hello,
I am building an Rails applications that has to integrate an legacy
system (lxoffice) (schema at:
http://www.lx-office.org/uploads/media/DB_Schema_2.1.1_R_393_17_03_2005_.pdf).
They somehow use global ids (global for some tables). I can not change
the schema and still I want to use Rails to access it and not pure SQL.
When I try to insert a record I get the following message:
2011 Sep 18
9
Rails 3 and postgresql
I have a simple project created around a very, very simple database: one
main table packs with just three rows
Column | Type |
Modifiers
--------+-----------------------------+----------------------------------------------------
id | integer | not null default
nextval(''packs_id_seq''::regclass)
nombre | character
2006 May 03
4
default values
Hello,
I''m working with a postgresql table
CREATE TABLE elements (
id serial primary key,
c1 text default f1(),
...
cN text default fN()
);
But if I use de lines
@element = Element.new
@element.save
the values that element take are the nextval in the id field and nules in
all the other fields.
How can I get the defaults?
(but without rewriting the
2006 Mar 01
7
Oracle Sequence & Rails
the compiler tell me it:
invalid column name: INSERT INTO ago.prova_stats (cognome, nome, id,
telefono) VALUES(''Medda'', ''Ivan'', :id, 70565611)
where ago.prova_stats is the table used by me and that have only the
columns ''cognome'',''nome'' and ''telefono''.
My table hasn''t the column
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 Feb 01
4
exclude a column in save!
Hi all,
I have a column that peeks its value from a sequence (postgres) some
times. Other times, I set it to a certain value.
This column has a default value of "nextval(''the_sequence'')"... When I
want that this column peeks the value from the sequence, I do this:
obj = Mymodel.new
obj.some_column1 = blah
obj.some_column2 = blah
obj.some_column3 = blah
obj.save!
but
2010 Apr 14
3
PGError: duplicate key
I''m running a rails 2.3.5 / ruby 1.8.7 / postgresql 8.4.2 app and have
just run into a curious problem.
I have several tables that are initialized with data from csv files
and I''ve noticed that, when I try to add new data to any of these
tables via Table.new I get a PGError on duplicate key.
For example:
MIGRATION:
class CreateNumbers < ActiveRecord::Migration
def self.up
2006 Apr 30
16
postgresql duplicate key violates unique constraint
I have a weird problem with creating a new record when using PostgreSQL.
From inside script/console ...
>> entity = Entity.new
>> entity.first_name = "Foo"
>> entity.last_name = "bar"
>> entity.save
Throws an exception due to the following SQL error: duplicate key
violates unique constraint.
The application was working fine before and suddenly
2005 Mar 09
6
auto increment id
looking at the unit tests of activerecord leads me to think the db is
completely responsible for auto-incrementing the id field and rails does no
magic here. can someone confirm that this is a true statement?
that being the case - what is the preferred way to write database agnostic sql
for one''s schema since each of the dbs has slightly different syntax for this
functionality... does
2007 Jan 23
7
ActiveRecord requires sequence numbers in Oracle join table
I am mapping ActiveRecord classes to an existing Oracle database. This
means I cannot change the database schema to fit ActiveRecord
conventions.
Predictably, I have gotten into trouble: I have several join tables
that do not have a primary key column, and therefore no number sequence
defined. ActiveRecord insists on requiring a sequence, and gets unhappy
when there is none to find.
Is there a
2013 May 19
5
update_attributes() for a single column
I was just faced with a strange ROLLBACK exception when attempting to
execute this code:
$ rails console
user = User.first
User Load (1.1ms) SELECT "users".* FROM "users" ORDER BY
"users"."id" ASC LIMIT 1
=> #<User id: 1, name: "Michael Hartl", email: "foo-+RB1Aph5k6s@public.gmane.org",
created_at: "2013-05-12
2006 Mar 21
7
Nuube Sequence problem
In my database the id for a field is 810. RoR thinks that it is 809.
My log file (below) shows that just before the insert it grabs the next
sequence value. I dont think it should do that. This causes problems
further down the line when trying to access the Person object.
Development Log file :
"SQL (0.016000) select people_seq.nextval id from dual
Person Create (0.015000) INSERT
2006 Oct 30
2
It this possible: finder_sql-like behavior for belongs_to?
Guys,
I have a need to support as has_many/belongs_to relationship on a
legacy(kind of) schema. The reason I say kind of is that the schema does
have "id" columns that are used in many associations, but this particular
has_many/belongs_to association needs to support different ones.
I''ve attached to code at the end of this email. Suffice it to say I need to
use the standard
2006 Mar 01
2
Oracle auto_increment ??? & Rails
To make a new istance of an Oracle table with Rails, i need that this
table had a column named ''id''. This ''id'' must be Primary Key &
auto_increment;.
How Can I modify the ''id'' properties to do it Auto_increment in Oracle?
--
Posted via http://www.ruby-forum.com/.
2005 Nov 30
8
nested attributes with update_attributes()
Hi,
I am trying to use the update_attributes on object with nested
attributes and I am getting the following error:
ProductPrice expected, got HashWithIndifferentAccess
Here''s the situation (simplified):
class Product < ActiveRecord::Base
belongs_to :productPrice
end
class ProductPrice < ActiveRecord::Base
has_one :product,
:dependent => true