Displaying 20 results from an estimated 600 matches similar to: "How to access atributes from a join table?"
2006 Mar 19
1
How to access attributes from a join table?
I have a table "domains", "users" and a join table of "domains_users"
which has the domain_id, user_id as well as a userlevel_id attribute.
I know that in the model User class I can set the value of this
attribute with a function that calls:
domains.push_with_attributes(domain, :userlevel => 1)
but how do I access the userlevel field so that I can use it later
2006 May 08
3
operator overload on views
In my User auth scheme I have a userlevel. I''ve overloaded the User
class operators like this:
def >(item)
if item.class == "User"
self.userlevel > item.userlevel
else
self.userlevel > item
end
end
(other operators are overloaded in essentially the same way). As I
understand it, using the operator ">" inside the overloaded
2006 Jan 02
2
ActiveRecord:
In the Agile Rails book, on page 232 (PDF, 4th edition) there is an
example of (within ActiveRecord) marking an article as read by a user at
the present time. Short example code (from the book) here:
class User < ActiveRecord::Base
has_and_belongs_to_many :articles
def read_article(article)
articles.push_with_attributes(article, :read_at => Time.now)
end
# ...
end
2011 Feb 15
2
Probe that fires on incoming IP and/or UDP (Solaris 10)
On Solaris 10, is there a probe that fires on receipt of an IP/UDP
packet? I''ve spent some time looking for one but can''t seem to find
what I want. (It''s unfortunate that its not running OpenSolaris as
otherwise we''d use the ip provider.)
What I''m trying to do is collect data on the latency between a packet
being received and it making its way into a
2006 Jan 20
11
HABTM relations
Hi,
I have 3 tables with HABTM relation.
USERS -> QUOTE_TO_USER <- QUOTES
Table QUOTE_TO_USER has 3 attributes: quote_id, user_id, component.
I have a form where I can tie multiple users to QUOTE. This is easy one,
thru "user_ids" (@quote[:user_ids] = @params[:quote][:user_ids]).
In this form I have all users and I just check those I want to tie to
this quote, however
2006 Apr 27
1
issue with deprecatiing push_with_attributes
I''ve been listening to the discussions regarding the plans to eliminate
push_with_attributes. While I think it''s good practice to make join models
if you''re developing a new system, I can''t help but think t hat
push_with_attributes should be left around to deal with legacy databases.
I might want to wrap my application around a database I don''t
2006 Mar 15
1
push_with_attributes not inserting default values
I have a join table A_B with columns[a_id, b_id, c_data default 1,
d_data default 1].
If I do:
@aobj.bobjs.push_with_attributes(@bobj,{:c_data => 0})
I find that the row inserted, has d_data set to 0 and not the default
value specified in the database, which is 1. So I am having to
explicitly set it using :
@aobj.bobjs.push_with_attributes(@bobj,{:c_data => 0, :d_data => 1}).
Is this
2005 Mar 13
1
Semantics of push_with_attributes
In trying to add timestamp support to habtm, I''ve stumped on a question
which I hope you all help me solve.
And that is, when adding a record twice to the list of associations with
push with attributes, should the following test succeed or not?
def test_pushing_twice
dev = Devel.new("name"=>"victor")
p =
2006 Apr 29
5
HABTM - how to insert join row when associated rows exist
I have successfully used HABTM to create a many-to-one-to-many set of
rows in one step. Now, if two objects I want to associate already exist,
how do I create the join row? The Agile book mentions the
''push_with_attributes'' method. The text says this method is useful for
adding additional attributes to the join row (in the example a ''read_at''
timestamp). I
2005 Dec 15
2
efficient INSERTS
Hi,
I''ve got the following models:
Company
Package
with a habtm relationship.
In my controller, I have a ''dispatch'' action which does the following
@companies.each do |company|
@packages.each do |package|
company.packages.push_with_attributes(package, :sent_on => Time.now)
end
end
my table ''companies_packages'' therefore lists which
2006 Mar 01
6
How to retrieve attributes from HABTM?
We have tables Users and Communities linked by has_an_belongs_to_many.
The join table Communities_Users has additional fields [ is_active,
is_blocked, join_date] etc. These are populated using
@user.push_with_attributes(:is_active => true,...).
Later on how do we update or retrieve the attributes in the link table
for a given user or a community with doing it explicitly using SQL?
Thanks,
2006 Jul 31
1
Use of push_with_attributes
Hi,
I have a model class called Page and a corresponding pages table in the
db.
Is there a way to do Page.new without actually creating a corresponding
record in the table? I want to set some values in it and then pass it to
the add_content_component() method in the class below which calls
push_with_attributes() which will actually create the record in the db?
class Page <
2007 May 03
1
Mac - Filesystem Size Limit?
Let me preface by saying I am not a samba expert. I've messed around
with the smb.conf file a few times, and mount to the shares regularly.
We are on 10.4.x on brand new Intel macs. We are mounting a samba
share that is approx 4.8TB, but only 1.9TB shows as the size of the
disk.
Is this a known limitation of samba on the Mac, or can it be fixed by
upgrading to a newer version of the
2009 May 24
1
Problems with ioloop on MacOS
I've been using the macports version of dovecot, which is 1.1.11, on
MacOS 10.5.6
$ /opt/local/sbin/dovecot --exec-mail imap
Fatal: kevent(EV_ADD, 0) failed: Operation not supported
This version is configured --with-ioloop=kqueue
The problem seems to be known, if not understood:
http://lists.apple.com/archives/Darwin-userlevel/2008/Dec/msg00010.html
However, if I use
2003 Feb 17
2
how to define share for sharing lmhosts?
Hi All,
Probably simple question: I want to make a share for sharing an lmhosts
file which gets included by the clients. This share has to be very
public and accept nullsessions (whatever that me be (no username and
password?)).
I want this because I need to generate aliases on the fly for for our
fileserver for some clients (terminalservers specifically). So I thought
that having an server
2006 Jan 02
1
ActiveRecord, << or push_with_attributes: update if exists?
In the Agile Rails book, on page 232 (PDF, 4th edition) there is an
example of (within ActiveRecord) marking an article as read by a user at
the present time. Short example code (from the book) here:
class User < ActiveRecord::Base
has_and_belongs_to_many :articles
def read_article(article)
articles.push_with_attributes(article, :read_at => Time.now)
end
# ...
end
2006 Jan 02
5
DB Modelling the Rails way - Opinions??
Hi,
I''m trying to figure the most efficient way to model the following. I
can think of at least two ways to relate the tables but from a
client/server perspective! I''m wondering how to best (and
elegantly)relate them from an AR perspective.
A project has many people,
A person can work on many projects at any time,
A project has many roles,
A role is performed by a person,
A
2006 Jun 05
7
Is HABTM Dying?
For a while, I''ve been getting that HMT is replacing HABTM. It appears that
HMT can do all of what HABTM can do and more. The question is: Should I stop
using HABTM? Let''s take a simple case:
A case has many categories
For a given category, there are certain valid statuses
Category
has_and_belongs_to_many :statuses
Status
has_and_belongs_to_many :categories
Question:
Is
2005 Mar 08
1
Updating Join Attributes
Other than doing a raw SQL update the only way to update join
attributes is to remove an object and then push_with_attributes
correct?
--
Lon
2006 Feb 07
1
habtm :uniq causing duplicate inserts? How to update Rails?
Hello *Gem* experts,
Sorry for asking multiple questions in one post but they are both related to one problem.
So far I have the following code:
class Member < ActiveRecord::Base
has_and_belongs_to_many :blogs, :uniq=>true
.....
end
class Blog < ActiveRecord::Base
has_and_belongs_to_many :members, :uniq=>true
...
end
The issue is that