similar to: Semantics of push_with_attributes

Displaying 20 results from an estimated 1100 matches similar to: "Semantics of push_with_attributes"

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
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 <
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
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
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,
2005 Dec 04
2
Adding sortables dynamically
Hi all, is there a way to define the containment option for a sortable so that it is a class name instead of an id list? I have a case very similar to the sortable lists demo, the only difference is that I'm adding new list containers dinamically, so either I need to redo the Sortable.create calls for all new elements to include the newly added container, or having someway to have them
2005 Jul 21
3
Question about sortables
Hi, I''m trying to use sortables to sort table rows and move them between different tables (yes, it''s actual tabular data ;). However, either I don''t know how to use the tag property of Sortable.create properly, or it''s only working for li''s. Since it''s probably the first option, could someone post an example of sorting tr tags and move them
2005 Dec 08
3
Uncomplete hiding on Firefox 1.5
Hi all, I have observed the following on Firefox 1.5 (both on XP and OSX): My page has some div containers that hold sortable ul. The div's also contain links for showing/hiding the contained ul's. No matter which effect I use to do the hiding and showing (Fade/Appear, SlideUp/Down, BlindUp/Down) the hidden ul's don't hide completely, leaving a blank 'trace' behind.
2005 Oct 04
5
sorting
I just want to confirm that it''s *not* possible to sort <tr>s in tables.... Jamie
2006 Mar 19
1
How to access atributes 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
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
2006 May 06
3
Storing additional data on join tables with Rails
Hi there I need to store additional attributes on join table. Searching the Wiki [1] revealed two possible methods: 1) push_with_attributes, as described by Justin Palmer [2]. Unfortunately, "this method is now deprecated" [3]. Even if it wasn''t, there seem to be inherent problems with that approach, for example with updating those additional attributes, though Joshua Muheim
2006 Jan 04
0
Re: DB Modelling the Rails way - solution by Chris Hall
Hi Chris, Yesterday you kindly submitted an answer to my question on modelling many to many relationships. I''ve briefly tried the proposed solution but so far with no luck. Before I get too involved - I''d like to know if mapping three way :join_tables is "legal" in a Rails sense. I only ask since you put (untested) in your mail and I can''t find any docs on
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
2005 Jan 25
4
Collection_select with multiple options
Hi, I have built a select field that allows multiple options selected with collection_select and "multiple"=>"multiple". How do I go about receiving the values? If I use a variable name like collection[], it complains that I can''t use @collection[] as the instance variable. TIA victor
2005 Dec 05
3
Multi-level drag and drop in scriptaculous?
I am trying to create a screen like Google''s personalized home pages or start.com, i.e., with draggable sections, with the extra feature that the child items under the parent headings could be dragged and dropped from one parent heading to another. I have set up nested droppable sortables (dropOnEmpty=true) but the behavior is very inconsistent, i.e, parents do not become droppable