Displaying 20 results from an estimated 1000 matches similar to: "Saving or updating multiple models"
2005 Dec 22
1
How to write unit tests with respect to model callbacks?
Hello,
I am exploring the "Testing" part of Rails, but It seems some things
work differently than I thought it would.
Consider the following model:
class Client < ActiveRecord::Base
has_one :project
def after_create
Project.new(:name => self.name, :is_client => true, :client_id
=> self.id).save
end
def after_update
2006 May 05
1
Adding methods to model based on foreign table rows
Hi all,
I wondered if the following is implemented in ActiveRecord:
I have three tables: "products", "properties" and "product_properties"
the products table holds base information for the product, like
product_id, name etc.
>> Product.column_names
=> ["product_id", "name"]
the properties table holds extra "columns" for the
2006 May 22
3
STI, HABTM & counter_cache
Hello world...
I have an interesting issue that the online docs aren''t helping me with.
In my app I have 4 models
Item < ActiveRecord
Deal < Item
Product < Item
Category < ActiveRecord
Item has_and_belongs_to_many :categories...
On each category record I''d like to maintain a product_count and deal_count
to increase performance. This doesn''t appear
2012 Jan 05
2
CentOS6 and tilde expansion
Set up NIS and autofs on this new CentOS6 box, but it seems tilde
expansion no longer works in bash?
[root at frodo ~]# cd ~john
-bash: cd: ~john: No such file or directory
[root at frodo ~]# cd /home/john
[root at frodo john]# pwd
/home/john
[root at frodo john]#
It still works in t/csh:
[root at frodo ~]# /bin/csh
[root at frodo ~]# cd ~john
[root at frodo ~john]# pwd
/home/john
[root at
2008 Jun 29
3
Working around/with Restful Authentication
I''m using Restful Authentication, and the code to create a user is
pretty straight forward - there is a before_save action and a
before_create action:
before_save :encrypt_password
before_create :make_activation_code
But for some reason when I try to create a user programmatically in
the controller like this:
User.new(:email =>
2005 Mar 04
3
optimization
Ok, so, I''ve written my first app in rails. It''s pretty nifty. Only
one problem. Slower than you could possibly comprehend.
Processing PersonController#show (for 67.138.254.231 at Thu Mar 03
21:04:16 Eastern Standard Time 2005)
Parameters: {:id=>"1", :controller=>"person", :action=>"show"}
[4;35mPerson Load (0.219000) [0;37mSELECT
2003 Oct 14
1
strange behaviour with ssh / stdin
hi,
i noted the following strange behaviour using ssh and linux. this is
probably a low-priority bug:
# ssh -V
OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
# uname -a
Linux funnyfarm 2.4.21-20.1.2024.2.1.nptl #1 Fri Jul 11 06:04:52 EDT 2003 i686 i686 i386 GNU/Linux
# echo Hello | ssh frodo 'cat'
Hello
# echo Hello | ssh frodo 'cat /proc/self/fd/0'
cat:
2006 May 26
3
Breakdowns in has_many abstraction
I discovered an interesting aspect of has_many behavior that I''m
struggling to work around. I''m not sure if I''m doing something wrong,
or if it''s a legitimate bug, or if it''s an inherent part of Rails that
I just have to learn to deal with.
It boils down to these two problems:
- changes in collection objects (i.e. models that belong_to a
container
2001 Mar 06
0
Continued utmp probs with sshlogin.c
Hi all,
I've hacked in some better logging for what's going on with my logins and
utmp/wtmp. Everything seems OK except for u.ut_host.
In my case, the actual variable host for this test case is
aragon.cheshirelaw.com. This is fine (as my logs show):
Mar 5 21:22:47 frodo sshd[10274]: Actual: 983852567 /dev/ttyp0
aragon.cheshirelaw.com
However, check out what u.ut_host is logged as:
2016 May 13
2
4.4.3 on CentOS 6: no guest login
I have built 4.4.3 on CentOS 6, with a fairly minimalist smb.conf,
provisioned the domain as per the wiki [1], and cannot get past test one:
[root at frodo ~]# smbclient -L localhost -U%
Domain=[ADTEST] OS=[Windows 6.1] Server=[Samba 4.4.3]
tree connect failed: NT_STATUS_CONNECTION_DISCONNECTED
I can get output if I specify a username, and give a password, but
anonymous access seems to be
2006 Apr 21
2
Using before_create and conflicting setter method...
Hi,
I am having trouble using before_create when I have an specialized
setter method:
before_save :set_campaign_start
#-----------------------------------------------------------------------
-------
def set_campaign_start
self.campaign_start = Time.now
end
# We want the date to always start at midnight
2016 May 13
0
4.4.3 on CentOS 6: no guest login
On 13/05/16 13:34, Tom Yates wrote:
> I have built 4.4.3 on CentOS 6, with a fairly minimalist smb.conf,
> provisioned the domain as per the wiki [1], and cannot get past test one:
>
> [root at frodo ~]# smbclient -L localhost -U%
> Domain=[ADTEST] OS=[Windows 6.1] Server=[Samba 4.4.3]
> tree connect failed: NT_STATUS_CONNECTION_DISCONNECTED
>
> I can get output if I
2006 Jul 04
1
select(object, method, choices, options = {}, html_options = {})
Hi,
I''m using:
select(object, method, choices, options = {}, html_options = {})
I''ve read the API where there''s this example:
select("post", "person_id", Person.find_all.collect {|p| [ p.name,
p.id ] }, { :include_blank => true })
should give this code:
<select name="post[person_id]">
<option></option>
2006 Jul 06
4
LVM Input/output error
Hi,
I recently installed centos for the first time and I like it!
Also, I just started working with lvm. The following warnings
are genertated whenever I run one of lvm commands on the external
usb disk (MyBook by Western Digital).
* What could be the source for those messages?
* Should I worry about them (writing into the created LV's
seems to work)?
* If yes, how to fix them?
[root
2006 May 16
1
:conditions on has_one realationship
Hi there,
I''m currently building a membership application and I want to be able
to select, not just all the memberships, but the most current
membership from the database on a per user basis. I have linked the
tables as shown:-
class Membership < ActiveRecord::Base
belongs_to :payment
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :memberships
2006 Jul 13
2
having a problem with acts_as_state_machine
Hi all:
Below is s a dump from script/console in development env.
Am I not supposed to be able to find the record later and use the
state machine functionality, or have I missed something? Thanks
Forrest
----------------------------
>> ts2 = TalkSession.create( :person_id => 2, :pattern_id => 2)
=> #<TalkSession:0x35811f0 @attributes={"pattern_id"=>2,
2006 Aug 01
0
Yum Transaction Check Error: package freetype-2.1.9-1.2.2.el4.rf
Hello list friends,
I got the following error during yum update.
How should I proceed to eliminate the probelm?
(I thought perhaps to uninstall the .i386 package -- but there
are some 15-20 other packages depending on it...)
Repositories: dries, kbs-CentOS-Extras, update, rpmforge, base,
addons, extras
FWIW: the protectbase plugin was added on 2006-07-10.
Thanks in advance,
Itay
2004 Sep 02
0
Need help with LDAP naming in SAMBA
Hi All
I am a newbie to Linux and Samba but getting thru it slowly and
successfully.I am trying to get the Linux server accesible from windows
and I need to know what the EXACT naming convention is for the LDAP
settings in Samba.
Here is the scenario
I have a MS Active Directory in place with a W2003 server acting as a
PDC emulator.The server is called Frodo and the domain is lab.co.za.
I
2009 Feb 27
4
Optimize for loop / find last record for each person
I want to find the last record for each person_id in a data frame
(from a SQL database) ordered by date. Is there a better way than
this for loop?
for (i in 2:length(history[,1])) {
if (history[i, "person_id"] == history[i - 1, "person_id"])
history[i, "order"] = history[i - 1, "order"] + 1 # same person
else
history[i,
2007 Nov 22
1
has_many :through questions
I''ve created the following associations using :through:
class Person < ActiveRecord::Base
has_many :attendees, :dependent => :destroy
has_many :events, :through => :attendees, :uniq => true
end
class Event < ActiveRecord::Base
has_many :attendees, :dependent => :destroy
has_many :people, :through => :attendees, :uniq => true