search for: primary_address

Displaying 5 results from an estimated 5 matches for "primary_address".

2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
I''ve got User has_one Shop. Rails is not validating when I tried create_shop or build_shop, neither in the browser nor the rails console. My code: class Shop < ActiveRecord::Base attr_protected :user_id belongs_to :user validates_presence_of :name, :primary_address, :city, :country_code, :currency end class ShopsController < ApplicationController before_filter :signed_in_user, except: [:index, :show] before_filter :correct_user, only: [:edit, :update, :currency, :update_currency] def new @shop = Shop.new end def create @shop = current_...
2010 Dec 07
1
fields_for and one out of many from association
class Person < ActiveRecord::Base has_many :addresses has_one :primary_address, :class_name => ''Address'', :order => ''preferred desc, id'' accepts_nested_attributes_for :addresses, :allow_destroy => true accepts_nested_attributes_for :primary_address, :allow_destroy => true end class Address < ActiveRecord::Base belongs...
2006 May 17
2
Association data clobbering (foreign keys too?)
Can someone please confirm or correct the following statements? If I have the following tables create table as (id int, [...], b_id int); create table bs (id int, [...], a_id int); create table as_bs (a_id int, b_id int); and the associations woould be defined like this class A << ... habtm :bs belongs_to :b end so my Model A has a habtm collection of Bs *plus* a direct
2006 Jan 25
12
DRY in Models
I am building an app right now that needs to grant access to three levels of members right now - each will have their own table in the DB. When creating the add_user action I am converting the password into a hashed password through the model. The way I am doing this right now, I will inevitably end up with repeated code in three different models. Is there a way I can define this code in
2006 Jul 05
19
associations question
Hello, I have a People table and a Addresses table. A person can have one or more addresses, but should at least have one, so there is a address_id field in People. Now, I would like to have a form to fill the name of a new person and its address from the same place. I could use person.address.country, for example (it works), but I would like to simply use person.country for some reasons