Displaying 20 results from an estimated 110000 matches similar to: "ActiveRecord"
2011 Jul 25
1
3 models in a form.
Hello,
class Customer < ActiveRecord::Base
has_many :deliveries
class Delivery < ActiveRecord::Base
has_many :delivery_items
has_many :products, :through => :delivery_items
belongs_to :customer
class DeliveryItem < ActiveRecord::Base
belongs_to :delivery
belongs_to :product
I create a new delivery for customer x:
= simple_form_for @customer do |f|
= f.simple_fields_for
2006 Feb 14
6
[newb] Find vs Find :all question
I''m playing out with writing an online store.
So far it has accounts, addressbooks, and orders, and those 3 are tied
together with an customer ID. I also have orderDetails, which are
associated to the order via an order number. See models below...
When I do the following I can access the orderDetails information just
fine:
@order = Order.find(params[:id]) # i pass it a customer
2006 Jun 17
2
how to delete a parent record and child records?
Wow, got myself lost as *soon* as I left the hand-holding exercises in
the books.
I''m trying to set it up so when I click the (scaffold-generated)
''destroy'' link on one (of a list) of parent MySQL records, the children
records in a different table get deleted also.
Very simple setup: my tables are ''customers'' and ''accounts''
class
2006 Mar 29
2
save related models from one form
I have three tables customers, indentities and people. I hav ecreated
models for them. The are connected with foreign keys and
has_many/belongs_to in this fashion:
customers has_many: identities
identities belongs_to: customer
identities has_many: people
people belongs_to: identities
Now, I have a form in which I would like to create db entries for the
three tables. customers have a password
2008 Apr 23
1
Validation dependent on unsaved parent
I''m having trouble with a validation that depends on an attribute of a
belongs_to parent. If the child is added to an unsaved parent
(parent.children << new child), the has_many collection
parent.children includes the unsaved child. However the belongs_to
attribute child.parent appears to be nil until the parent has been
saved. Without access to the parent attributes, the validation
2006 Apr 07
0
Custom Non-ActiveRecord Classes or not...
Say I want to gather info from various Models... Files, Folders, and put
them into a ''display'' Object DisplayFilesystem that will standarize the
info from both tables (for display only)...
Class DisplayFilesystem
attr_accessor :item_id, :name, :type, :description, :date
def initialize
@item_id = @name = @type = @description = @date = nil
end
end
So in the code side
2011 Jul 26
1
ActiveRecord has_many associations
Given the models Country, State, City and Person as follows.
class Country < ActiveRecord::Base
has_many :states
end
class State < ActiveRecord::Base
belongs_to :country
has_many :cities
end
class City < ActiveRecord::Base
belongs_to :state
has_many :people
end
class Person < ActiveRecord::Base
belongs_to :city
end
Is there any way that doesn''t allow to delete
2006 Mar 21
3
Newbie - ActiveRecord relationships
So I''ve worked through Agile Web Development with Rails and I''m now
trying my first little app to get into the swing of things. Its a task
tracking app where people can create tasks and assign them to others,
and also log time against the tasks.
I''m having trouble working out the model relationships. This is what
I''ve got so far, but its not right as
2010 Apr 25
0
Rails3: ActiveRecord includes(:) not working
class Customer < ActiveRecord::Base
has_many :projects
end
class Project < ActiveRecord::Base
has_many :works
belongs_to :customer
end
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this
2007 Sep 05
8
Hi..Guys new plugin again
Hi..
Guys new plugin again
Foreign Key Associations is a plugin that automatically creates
associations based on foreign-keys. The associations are created at
runtime-ie. as your ActiveRecord models are loaded-so they will always
be up-to-date.
For example, given a foreign-key from a customer_id column in an
orders table to an id column in a customers table, the plugin
creates:
2006 Nov 04
0
ActiveRecord
I''m running into a bit of a ideological and functional problem with
ActiveRecord and would like to find out if some of these concerns are
valid. Hopefully someone here already knows the answer...
The concerns are that ActiveRecord has a lot of activity involving data
validation (validates_uniqueness_of, validates_associated) and model
definition (belongs_to, has_many, has_one).
2009 Oct 07
2
"Overriding" association build methods
Hey everyone
I have (in a nutshell) two models: Customer and Order. Customer
has_many Orders and Order belongs_to Customer. The Order model
contains fields such as name, address and phone that mirror the
associated Customer''s fields at the time the order was placed. The
reason for this is that if the customer changes their details then the
order contains the details that were current
2010 Nov 11
5
ActiveRecord query
I have these sql code in postgresql
"SELECT * from convenios where id NOT IN
(SELECT convenio_id from solicituds where usuario_id=?"
but don''t find a way of used it in rails
except
find_by_sql.
There is a another way??
class Usuario < ActiveRecord::Base
belongs_to :persona
has_many :solicituds, :dependent => :destroy
has_many :convenios, :through =>
2007 Nov 19
2
Help with controller and view
I have the following models
class Recipe < ActiveRecord::Base
has_many :ingredient_recipes
has_many :ingredients, :through => :ingredient_recipes
end
class IngredientRecipe < ActiveRecord::Base
belongs_to :ingredient
belongs_to :recipe
end
class Ingredient < ActiveRecord::Base
has_many :ingredient_recipes
has_many :recipes, :through => :ingredient_recipes
2006 Mar 31
3
Complex Through Statement
Quick Overview:
I have an ''Employee'', some ''Merchants'' and some ''Products''. A
''Merchant'' has many ''Products''. An ''Employee'' has multiple ''Merchants'',
depending on their relationship. For example, the Employee may be the
enrollment contact for one merchant and the
2006 Mar 03
2
Through relationship
I am working on streamlining one of my apps, and trying to wrap my
hands around through, polymorphic, and with_scope. All of these i
know i need for what i want to do, based on the little documentation
I have found. With this in mid I have tried to implement a simple
through in the app to try and get my head around it. This is what I
have:
class Product < ActiveRecord::Base
2006 Jul 24
3
HowTo?: Eager caching of third order ActiveRecord assoc.
Hello.
Using the ":include", which generates a "LEFT OUTER JOIN" SQL command,
it is possible to eagerly preload second order data objects (children)
for a given association.
I wanted to know, if it is possible to eagerly preload and cache
third order (or more) data objects, which are little-children or
little-little-children. As I''ve seen. it is possible to add
2010 Mar 10
0
Rails ActiveRecord associations autosave option
I have the following associations.
class Document < ActiveRecord::Base
has_many :document_sections, :dependent => :destroy, :autosave => true
has_many :document_items, :through => :document_sections
end
class DocumentSection < ActiveRecord::Base
belongs_to :document
has_many :document_items, :dependent => :destroy, :autosave => true
end
class DocumentItem <
2006 Aug 03
3
Relationships between models.
Hi All,
I think Im having a mental block here. For some reason I just cant get
my head round relationships.
What I have is the following.
4 tables
1) Hosts
2) Software
3) OperatingSystem
4) Company
In my terms (which are most likely wrong) a company can have lots of
hosts, a host has lots of software, a host has one operating system.
So should my models have the following relations in them?
2009 Jun 22
5
has_many through , or habtm , using form
i think there ara two ways of relate products and categories ,
basically i want to fix one product(e.g hp dv7....) to some categories
(notebook,17"notebooks...)
i made a table named categorization(incuding category_id,product_id
fields) then in models i write these codes below
class Product < ActiveRecord::Base
has_many :categories, :through => :categorizations