Displaying 20 results from an estimated 60000 matches similar to: "Truncate table to reset id back to 1"
2009 Mar 17
3
How to truncate a table from a rake file
I am new to rails and want to figure out the syntax for truncating a
table using a rake file. Any ideas? thanks in advance!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
2006 Nov 27
3
ActiveRecord: Reference same table twice
Hi,
I have 2 tables, "users", and "user_comments". I am trying to allow
users to leave comments on each other''s profiles (eg, think youtube like
this: http://www.youtube.com/profile_comment_all?user=google).
Here is a simplified view of my database schema:
mysql> describe users;
+-----------------+--------------+------+-----+---------+----------------+
| Field
2006 Mar 29
2
delete_all not resetting auto incement in database
Hey
I''m writing a simple admin interface thats reading user data (skills)
from a comma separated file.
To clear the database before inserting new skills, I use
Skill.delete_all
Then I insert the new values I read from a file. Everything goes well
up to the point where I see that auto-generated ID''s are not starting
from 1. They start off at 840 (responding to the number of
2009 Mar 02
3
Truncate function and html tags
I have a text field in the db for the body of user posts. Users
submit the posts using the tinymce editor, which allows certain html
tags. The posts are stored in the db with allowed html tags directly
in the post, so I could have something like:
<p>This post will try to eliminate the confusion regarding rails and
the truncate function.</p>
I am trying to display the first 300
2008 Sep 04
3
MySQL connection collation
Hi!
I have ran on problem with collations. In database.yml I have set:
encoding: utf8, but when in console run:
>> ActiveRecord::Base.connection.collation
=> "latin1_swedish_ci"
It is Rails 2.1, mysql gem 2.7, mysql 5.1.22. This leads to errors like:
Mysql::Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
(utf8_general_ci,COERCIBLE) for operation
2007 Mar 29
1
improving on: truncate(..) + rendered text ?
Hello all,
In a summary page I need to show the 1st 100 chars of textilized messages.
Problem: truncate(..) would often cut in the middle of html tags =>
random result.
My first idea was to "repair" the broken text with Hpricot (as I use
it elsewhere in the project), but it''s not perfect:
<h1>abcd</h
would give
<h1>abcd</h</h1>
(I also use
2006 Oct 31
4
Auto-increment lost during migration.
Hi. I get some strange results when using rename_column on a primary
key in a migration. It seems like the migration script removes the
auto-increment property if you rename a column.
This is a minimal example.
create_table :foo, :primary_key => :foo_id do |t|
t.column "name", :string
end
# renaming the primary key makes auto-increment disappear.
rename_column
2009 Mar 05
6
About before_* callbacks
Hi
I have an problem about before_* callbacks.
I have a model named: Event
And I don''t want anyone to destroy or update any records in Event
model.
So:
[code]
class ActiveRecord::Base
before_destroy :log_illegal_operations
before_update :log_illegal_operations
private
def log_illegal_operations
Event.create({:key => "illegal operation", :value =>
2009 Aug 31
3
Migration - wrong SQL statement is created
Hi,
I am doing my first steps with RoR and I have the following problem:
I execute my migration file with the following content on a
MySQL-database via Rake:
<code>
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.integer :id
t.string :username, :size => 100
t.string :password, :size => 100
t.string :email, :size
2009 Jul 04
3
scaffolding
hi , i used the folllwing command to scaffold,
G:\my\webblog>ruby script/generate scaffold webblog id:integer
title:string body
:text created_at:datetime
after when i migrate with the follwing command
rake db:migrate
i got the error as
(in G:/my/webblog)
== 1 CreateWebblogs: migrating
================================================
-- create_table(:webblogs)
rake aborted!
Mysql::Error:
2006 Jul 21
3
Migration and Mysql row ID
Apologies if this has been discussed before, but with the search
function down its hard to find out if it has
The first Agile book recommended using the automatically assigned row id
of an object as a foreign key reference, as rails would automatically
interpret the attribute (for example) product_id as the table ''product''
and row ''id''.
I''ve just
2007 Jan 20
3
Making tables with SQLight
Hi, Im using locomotive and running SQLight. Im confused about making
tables with sqlight.
Im following the depot example from ''agile web development with rails''.
When trying to make the table ''products'' is there a difference when
using SQLight rather than MySQL?
Here is the DDL for MySQL, how do I make this table with SQLight?
-
drop table if exists
2008 Jun 09
16
display "..." for text LONER than a certain length...
I am working on an app that has user generated content. What I''d like
to do, is display X characters of, say, a title and put "..." for the
rest. This sounds like something you see in soc networking type app
and wondering if there is some code out there to do this. thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed
2006 Jan 08
4
ID from child table not handled by AR
Hi all,
Im slowly moving forward, but there''s something a miss. I can save some
relational records to tables, but only once. For an unknown reason, the
primary key (id) of the child table is not automatically increased. (I can
only perform one save, (the first records id field holds the value ''0'') and
during the next save it says:
Mysql::Error: Duplicate entry
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
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 Nov 01
4
MySql Errors On .save
Hi All,
I am a real neophyte with Rails and am struggling with something. I hope
you can point me in the right direction.
I have a model of an object that
class Thing< ActiveRecord::Base
attr_accessor :locator_id
has_one :otherthing
has_one :differentthing
end
I can create and delete these things until the cows come home. However,
trying to change the data and save/update I get a
2006 Sep 29
1
newbie Q: it won't display foreign keys...
I have two tables
CREATE TABLE continents (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE countries (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL,
continent_id int(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I generate scaffolds for country and for
2018 Aug 01
1
Re: [PATCH v2 nbdkit 5/6] Add truncate filter for truncating or extending the size of plugins.
On 08/01/2018 06:10 AM, Richard W.M. Jones wrote:
> This can truncate, extend, or round up/down to a multiple.
> ---
> common-rules.mk | 3 +-
> configure.ac | 1 +
> filters/offset/nbdkit-offset-filter.pod | 7 +-
> filters/partition/nbdkit-partition-filter.pod | 1 +
>
2007 Sep 29
8
Inheritance problem in model
Hello,
I''ve got a problem with the inheritance as soon as I try to use it in a
model.
I''ve got plenty of items which can share a lot of code, so I created a
class "Item", which inherits from ActiveRecord::Base, but because it''s
not a "real item" but an interface, I set it abstract (writing
abstract_class? method).
Then I have all the differents