similar to: `build_association` produces DB-queries

Displaying 20 results from an estimated 10000 matches similar to: "`build_association` produces DB-queries"

2009 Nov 13
1
Delegates and building associations
Class User << ActiveRecord::Base has_one :profile delgate :description, :description=, :to => :profile end I''d like to do, @user = User.create(:name => ''Foo Bar'', :description => ''Slow.'') or @user = User.update_attributes(:description => ''Slow'') and have AR create/update the profile model and association (if
2008 Sep 11
0
session/marshalling
I have the following problem with marshalling/saving a model to session. I have 4 models: User, Profile, Customer, Membership. Membership belongs to the other three models, and User, Profile and Customer all have a has_one :through => :memberhsip association to each other. Now I have a registration process over several steps, including the creation of all 4 models. Partially the validation of
2012 Sep 13
0
Accepting build_association parameter for fields_for helper or build association object automatically
Do you think will it useful to include in rails functionality of this gem<https://github.com/ka8725/get_or_build>(get_or_build)? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/6vNMq94gdb4J. To post to this group, send email to
2006 Aug 14
5
Tutorial for Queries
Hi! I''m looking for a good tutorial that explains the main points of performing queries with Rails. I do have AWDWR and have read the section on ''find'' but I''m looking for something that goes into more detail on how to perform queries across tables. Abstracted from my current application, this is an example: * person has_many sites * site has_one room *
2005 Dec 15
3
Another session question
I want to give a user a form to create a new Product, but instead of persisting the product to the database I want to store it in a session first for category assignment, etc.. (in other controllers) So when the user describes the product on the form I have a "Save and Continue" button pointing to the action add_to_product_factory: def new_product @product = get_product end
2012 Nov 15
2
Suggestion: use `select` values if `pluck` called with no args
I suggest that if you don''t pass any args to ActiveRecord#pluck, it would use the select values. This follows along well with the way other AR::Calculations work. As an extra benefit we would be able to pluck virtual columns. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit
2007 Apr 04
4
joining across databases in a find statement with include (legacy db)
Hi, I have a legacy database ''old'' and a new database ''new'' which rails uses. I set up models using old with establish_connection(old), and this works well, except for include: class OldModel < ActiveRecord::Base establish_connection(old) end class NewModel < ActiveRecord::Base has_one :old_model end a = OldModel.find :first NewModel.find(:all,
2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my has_one :through association. I have Users, Profiles and Customers, all connected to each other with a has_one :through => :membership association like this: class Profile < ActiveRecord::Base #could also be user or customer has_one :membership # i saw an acrticle of Ryan about has_one :through, there this would be has_many, is
2006 Jun 14
1
compare items from 2 db
I''ve dug thru docs, recipes, wiki, but haven''t found anything quite like what I''m trying to do.. I have 2 databases with the same tables and same models representing them. I want to get an item (of same name) from the 2 dbs for comparison. Now, each example of connecting to multiple dbs I''ve seen (including from Rails Recipes and the wiki) assumes that
2007 Aug 15
5
PuppetDatabase - collection "yes", anything in db "no"
Hi there! I´m trying to get my PuppetmasterDB running. Problem is, though I´m not getting any errors from the puppetmaster there is nothing stored in the database, not even tables are created. I tried "puppetmasterd --dbmigrate", didn´t help either. rails.log is kinda empty too.. Thing is: it kinda works anyway, there is just nothing stored in the DB - exported a user on host A,
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again. I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I don''t just post it manually: I design a Rails-based inventory database that creates a semantically-correct XHTML/CSS auction
2006 May 12
1
can I fake has_one :through?
I''m having a difficult time wrapping my head around a set of models and their associations and seeing how they map into Rails. I''ll try to lay out my problem using the has_many and belongs_to structures. I have a RuleSpace, a Rule, and a Subject. A RuleSpace has_many Rules A RulesSpace has_many Subjects through Rules A Rule belongs_to (many) RuleSpaces A Rule has_many
2010 Aug 10
4
(Dreaded) STI, belongs_to
Having problems with STI. Names below have been changed to protect the innocent. Imagine a system that allows someone to apply for one of two different types of school scholarships. Each scholarship goes through a different review process, represented by a state machine (this is not a state machine question). So there are two state machine classes that differ slightly and subclass a generic
2006 Mar 19
2
Multiple polymorphic belongs_to declarations
I have the following models: class Card < ActiveRecord::Base belongs_to :deck belongs_to :front, :polymorphic => true belongs_to :back, :polymorphic => true end class TextContent < ActiveRecord::Base has_one :card, :as => :front has_one :card, :as => :back end The conflicting has_one declarations don''t work. What I need is
2008 Sep 29
1
has_one :through with :source. How to alias association?
Hi to everyone, I have the following models: class Attachment < ActiveRecord::Base has_attachment :content_type => [:image, ''application/pdf''], :max_size => 3.megabytes, :path_prefix => ''../private/attachments'', :storage => :file_system, :processor => :rmagick,
2006 Jul 30
3
ActiveRecord - Multiple Address for a single record
I''m trying to figure out the Rails way to model the following problem: I have 2 tables. One (let''s call it location) contains a single address. The other (let''s call it company) contains 3 address. I''m trying to figure out the best way to model this. I''ve created an address table, a set up the model as follows: class Address <
2006 Aug 16
5
Rails theory question, where to put a join query
The is something I wrestle with a bit when I construct joined queries.. Perhaps some experienced insight will straighten this out for me. Say you have two tables with two models, ''authors'' and ''posts''. an author has_many posts, a post has_one author. You need methods to do the following queries: find_author(postid) find_posts(authorid) And you are doing a
2010 May 25
2
Site Navigation With Polymorphic Has Many Through
Hi, seem to keep running into a wall here. I can''t find any resources on site navigation that can deal with any model being in the nav, allow nesting, and can dynamically update. So I thought about it for a while, and decided on a MenuItems class, which contained the position of the child in relation to it''s siblings, where the parent and the child were polymorphic. Then a given
2006 Feb 26
3
Rails Naming Conventions
DB field names: If I have a table that references 2 or more separate users from my users table, is there a recommended naming convention for this situation? In my case, I have 3 users associated with a record in my projects table: requester_user_id created_by updated_by I could name one of them "user_id", and then projects.user would work I guess, but wouldn''t work
2006 Mar 23
4
belongs_to more than one model
Suppose I have one table: states id statename And I have two other tables that contains states: houses id color state_id places id place_name state_id How would my model relationships look like? class State < ActiveRecord::Base belongs_to house belongs_to place end class House < ActiveRecord::Base has_one state end class Place <