Displaying 20 results from an estimated 20000 matches similar to: "ActiveRecord batch insert for MySQL"
2005 Sep 11
3
Extending ActiveRecord::Base
Hey everyone,
I''m interested in extending ActiveRecord::Base. I have a special
"easier" find function that I want to include in all classes.
How can I include this in all classes?
Can I just create a model object that does something like this:
class ExtendedAR < ActiveRecord::Base
def self.special_find
...
end
end
and then all my other classes
2006 Jun 30
14
Saving boolean attributes
Hi,
I''m just learning Ruby on Rails and ran into something where I know I''m
either doing something very stupid or I''m missing something.
My model as a boolean attribute called active_flag. In my Sql Server
database this is stored as a bit value. I then setup a method in my
controller called "deactivate". This is very simple, it does:
def deactivate
2005 May 14
2
ActiveRecord::Associations::ClassMethods Documentation Issue
I''m curious, but isn''t this example in the documentation for
ActiveRecord::Associations::ClassMethods somewhat counter-intuitive? The SQL
DDL is correct for the way it''s used in the models. But isn''t it more
logical that an author would have many posts, rather than many authors
having one post?
From
2012 Mar 22
6
rescuing ActiveRecord::RecordNotUnique: clever or ugly?
I have an ActiveRecord that has several foreign keys, where the foreign
keys act as a single compound key that needs to be unique:
class CreateRelations < ActiveRecord::Migration
def change
create_table :relations do |t|
t.references :src, :null => false
t.references :dst, :null => false
end
add_index :relations, [:src_id, :dst_id], :unique => true
end
end
2008 Apr 24
0
ActiveRecord - INSERT options for MySQL
Hi,
Excuse any mistakes I make in advance- this is my first post to the
RoR list, and it''s going right in at the deep end...
I''ve been working with Rails for quite a bit now (8ish months or so)
and I''ve worked on two projects where there are several points in
which access to INSERT statement options would be extremely useful.
I''m using MySQL, where there is
2007 Mar 18
5
Automatically mocking ActiveRecord methods
Seems like I do a fair amount of mocking ActiveRecord''s automatically
generated routines when I''m testing controllers. Things like:
@portalspace = PortalSpace.new :public_readable => true,
:public_writable => true, :name => ''public''
@portalspace.stubs(:id).returns(203)
PortalSpace.stubs(:find).with(203).returns(@portalspace)
2007 Jan 25
6
NOT FOUND error
I''ve been hunting the web and reading the mailing lists all day but
I''m not finding any guidance on this problem. When I try to talk to my
mongrel it simply responds with NOT FOUND and nothing else. I can''t
find anything on google because this has to be the second most commond
phrase in existence.
Any help or guidance would be greatly appreciated.
Sincerely,
Chuck Vose
2006 Jul 07
4
Calling a method each time an ActiveRecord Object is accessd
Hi,
I know that it is possible to execute code each time data is saved into
a model by using the +validate+ method.
However, is there also a way to execute code each time the data is
accessed, not just when it is changed?
Bye,
Winsmith
--
Posted via http://www.ruby-forum.com/.
2006 Jan 11
7
Create a relationship with 2 or more tables on 1 insert
userstable: |id|name|password|
userdetailstable: |id|col1|col2|col3|user_id|
this is my code:
[code]
def create
@user = User.new(@params[''user''])
@userdetail = Userdetail.new(@params[''userdetail''])
if @user.save and @userdetail.save
flash[:notice] = "Save succeeded..."
redirect_to :action => ''list''
2010 Oct 20
0
read-batch: Skipping batched update..No batched update inconsistency
I already asked this question before, some
time ago (a few months), but got no reply.
We're using a backup system based on rsync
and batched updates.
Quite often I see a situation when rsync refuses
to apply next batch with the following messages:
applying f0002.rgs-podm.ru 142
(Skipping batched update for "etc/cron.d/sysstat")
(Skipping batched update for
2018 Jan 09
2
[PATCH net-next] vhost_net: batch used ring update in rx
This patch tries to batched used ring update during RX. This is pretty
fit for the case when guest is much faster (e.g dpdk based
backend). In this case, used ring is almost empty:
- we may get serious cache line misses/contending on both used ring
and used idx.
- at most 1 packet could be dequeued at one time, batching in guest
does not make much effect.
Update used ring in a batch can help
2011 Apr 09
4
API documentation for find_in_batches
Hello,
At guides.rubyonrails.org I read about the possibilities of
find_in_batches. However I cannot find this option anywhere in the API
documentation (api.rubyonrails.org).
My question: where should I look for the documentation of this
command?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email
2009 Mar 07
0
Be careful of BIGINT primary key fields in MySQL. Will cause problems with ActiveRecord create (but not find)
The MySQL/Ruby library doesn''t properly handle inserts into tables
with the primary key being a BIGINT
If the ID returned to the MySQL/Ruby library is LARGER than the INT
range, the value is returned to Ruby truncated and incorrect. This is
then passed up to ActiveRecord and into the id field of your model.
The actual INSERT worked properly and when do you an ActiveRecord find
for the
2006 Mar 29
2
inserts now set unset columns to null
Hi,
I upgraded to Ruby 1.8.4 and whatever the latest Rails is as of March 29
2006.
I am using PostgreSQL 7.4.
With the earlier version of rails, I had insert queries that looked like
this:
Topic Create (0.001189) INSERT INTO topics ("inlibrary",
"irx_display_title", "irx_title", "title", "creation_stamp",
"last_update_stamp",
2006 Jul 18
3
Navigation techniques, everyone?
I''m rewriting the code to my first app. I want to reuse a lot of it,
but tidy it up a lot. The first thing I will tackle is my nav-bar.
Throughout a user''s experience on my app, I want it to reload as little
as possible (I''ll have about 7 or 8 controllers with about 70 actions).
So, I''ve thought of a few ways of doing it, and was wondering if you
guys
2006 Jul 08
2
Creating/Saving dependent objects
Folks,
Am new to RoR and am building an example to get myself familiar. I am
running into a simple issue while creating a user registration page.
I have a User and Address models defined as below (partial/relevant code
included below). User has_one address and Address belongs_to user. I have a
foreign key defined in address table that refers to user(id)
In a form I take in username, password,
2006 Jul 06
6
Problem with gettext and functional tests
Hi,
I am using gettext to let my web application know several languages. All
works fine, but since I integrated it, my functional tests don''t work any
more.
I keep getting the error message:
NoMethodError: undefined method `cgi'' for
#<ActionController::TestRequest:0xb77f7f88>.
All right, TestRequest doesn''t have a cgi method. Therefore I just included
this into
2006 Jul 06
9
Where to put code - controller or model
I have a Rails app that is a directory indexer. It passes the desired
directory path in the url.
There is a user table, and a permissions table (which contains the
volumes each user has permission to see). There is also a volume table,
which contains the available volumes, and a path table, which contains
the paths to every file available on the machine. [There are other
tables, but these
2006 May 16
5
Transactions in RoR
Hi,
Does anyone knows how to manage transactions in RoR.
Thanx
2006 Apr 20
5
strange mysql problem
i have this model:
class LineItem < ActiveRecord::Base
belongs_to :quote
end
in the console:
>>l = LineItem.create
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '' , , , )'' at line 1:
INSERT INTO line_items (`qty`, `quote_id`,