similar to: confused about ActiveRecord relationships

Displaying 20 results from an estimated 1000 matches similar to: "confused about ActiveRecord relationships"

2006 Apr 04
5
Database usage technique -- user-specified fields
Hello folks- In one particular app, it would be useful for the customers to be able to specify the significance (and presence) of fields. For example, consider a CONTACTs database. User 1 wants to have phone1, phone2, phone3, and User 2 wants to have 4 address fields. Generically, this could be done by having a CONTACT with, say, 10 strings, 10 integers, etc. The user''s account
2008 Apr 10
3
Custom Form Builder Help
Hello All, We use a different custom form builder for our app, but I wanted to use facebooker''s typeahead widget in side the other form builder. I don''t know much about form builders, but I created a file in lib/ doing this: http://pastie.caboo.se/178776 It works great, except that the id''s and class names get messed up. Instead of school_name, I get
2007 Feb 04
0
Very strange observe_form problem
I am doig something very simple here and this is not working correctly. So any help is greatly appreciated. I ahve this code in my template: <% form_for :company_branch, @company_branch, :html => {:id => "company_branch_form"} do |f| %> <%= f.text_field :street1 %> <%= f.text_field :street2 %> <% end %> <%= observe_form("company_branch_form",
2007 Oct 11
0
display problem with to_csv
Hi all, I need to export the document as csv file, i have exported successfully, but the problem is not displayed as per my format, in csv file the format is suffuled, i want the orderwise as how i have mentioned in my query, please help me to come out in the order wise. My coding is: @report_data=EdiaUserContact.find_by_sql( "SELECT '''' as ''Title'',
2006 Feb 08
1
Weird validation issue
Hi, I''m having a weird validation issue. Validation isn''t working for certain attributes and, for some reason, it''s also affecting things outside of validation. For campers on certain camp types, we require some information about their school. I tried to validate the information this way: validates_presence_of :school_type, :if => Proc.new { |c| !c.booking.nil?
2007 Jul 21
2
avoiding timconsuming for loop renaming identifiers
Hi All I was wondering if I can avoid a time-consuming for loop on my 600000 obs dataset. school_id y 8 9.87 8 8.89 8 7.89 8 8.88 20 6.78 20 9.99 20 8.79 31 10.1 31 11 There are, say, 143 different schools in this 600000 obs dataset. I need to thave sequential identifiers, 1,2,3,4,5,...,143. I was using an
2006 Jan 27
4
acts_as_whatever
Hi there, I love the acts_as_* family that rails uses. I''ve also found I can create something similar by dropping the following code into my activerecord classes: class MyClass < ActiveRecord::Base class << self alias_method :count_with_unapproved, :count end def self.find(*args) options = extract_options_from_args!(args) if options[:conditions].nil? options[:conditions] =
2006 Apr 04
4
Aggregating two objects of the same type
I would like to have a customer that has references to two addresses, a billing address and a shipping address. In a non-rails environment I would have two keys in the customers table, billing_address_id and shipping_address_id to reference the addresses. It appears that ActiveRecord expects the parent id to reside in the child table, regardless of whether the relationship is one-to-one or
2009 Feb 26
1
composed_of, aggregate object isn't saved
I am relatively new to rails and I cannot figure out what is going on here. I am using the composed_of method in an ActiveRecord class to create two aggregate properties: shipping_address and billing_address. The object properties are getting populated from the form and validation is working - no problem. When I call order.save, though, everything is being saved except the address fields. I am not
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 Jul 31
2
Updating a belongs_to foreign key leaves the old association object available
Perhaps this is intentional, but it seems unlikely: class Person < ActiveRecord::Base belongs_to :school end p = Person.find(:first) p.school # nil p.school_id = School.find_by_name(''High School'').id p.school.name # High School p.school_id = School.find_by_name(''Primary School'').id p.school.name # High School <= Shouldn''t this be Primary
2013 Dec 10
2
form_tag + fields_for Rails 4
Hi There, I''m trying to user fields_for inside a form_tag, but i can''t catch it on my controller. I just take some html code off to makes it easy to read my view... i''m using campuses_path(current_church, @campus) instead form_for @campus, because my route is like resources :campuses, :path => ":church/campuses" <%= form_tag
2007 May 28
5
validates_uniqueness_of does not pass unit test
I am doing some very very basic unit testing. If I take away the uniqueness validation, the tests pass. Could this be a bug in Edge Rails? --~--~---------~--~----~------------~-------~--~----~ 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
2008 May 25
2
record will absolutely not save! so weird, please help.
I have a weird problem going on. All of sudden, records for a certain model will not save with #save Please take a look at this: >> p = Payment.new(:payment_reason_id => 1, :payment_method_id => 1, :date => Date.today, :amount => ''5.00'', :payable => Student.find(608)) => #<Payment id: nil, school_id: nil, payment_reason_id: 1, payment_method_id: 1,
2006 Mar 24
7
Polymorphic associations?
I''ve read the stuff about polymorphic associations here: http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations But I''m not sure what exactly they are and what their advantage is. Are they the same as HABTM, but they''re "two-way"? Joe -- Posted via http://www.ruby-forum.com/.
2006 Feb 11
2
Migrations and Unintialized Constants Error
I am running into a problem with two of my tables and the "uninitialized constant" error when using migration. I get the "uninitialized constant Note" when running the following code in my migration file: create_table :notes do |t| t.column :id, :integer t.column :noteshare_id, :integer t.column :title, :string t.column :covered, :string
2006 Feb 03
6
Saving a User Object while in the Address Controller
Hi, My saves are failing me and I can''t figure out why. I am trying to save an address id to a user object just after I create the address. This isn''t the exact code, but it shows what I am trying to do. class AddressesController < ApplicationController def create @address = Address.new(params[:address]) saved_address = @address.save @user =
2009 Feb 23
2
geokit - using :through to connect models
hello.. i am currently trying to use :through to attach two of my models together using geokit. for some reason, i am running into a problem: ArgumentError: Unknown key(s): as i have two models, one that is geocoded, and one that belongs to that model. the models look like: ,----[ employer.rb ] | class Employer < ActiveRecord::Base | acts_as_mappable | before_validation_on_create
2006 Jan 09
3
Design Question
I am sure some of you can give me an insight into this. This is more towards the database design for the scenario below: Say for example, I have a person table and this person can have different address types. One could be Home and the other could be say Office. Should be model this Table people id fname lname Table addresses id person_id addr1 addr2 .... or Table people id fname lname
2008 Apr 07
5
Associations errors
undefined method `each'' for 0:Fixnum at line @school = School.find_by_title(params[:school_id].gsub(''-'', " ")) for team in @school.teams ........ end @school does exist cause i tried with .find(:first) and it gave the same error. Also I''m getting undefined method `reject'' for #<Game:0x24ca1c4> From @home.game_ids = @game