similar to: ActiveRecord::Associations::ClassMethods Documentation Issue

Displaying 20 results from an estimated 9000 matches similar to: "ActiveRecord::Associations::ClassMethods Documentation Issue"

2008 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message. I am new to RoR, and ruby too, but i am quite excited about it. I am developing a RoR project and with active record associations in the following manner # Tables (all tables have only one record) CREATE TABLE `webcars_development`.`cars` ( `id` int(11) NOT NULL auto_increment, `model_id` int(11) NOT NULL default ''0'',
2007 Jan 17
1
include ClassMethods in plugins
Why is that in so many plugins I see people using (including acts_as_taggable by DHH): # init.rb ActiveRecord::Base.send(:include, ActiveRecord::Acts::SomeModule) # lib/some_module.rb module ActiveRecord module Acts module SomeModule def self.included(base) base.extend(ClassMethods) end module ClassMethods def acts_as_something # code
2005 Jan 07
3
multicolumn primary keys in activerecord
hi, I''ve got the following tables in mysql notation: CREATE TABLE `nodes` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default ''0'', `group_id` int(11) default ''0'', PRIMARY KEY (`id`), ); CREATE TABLE `groups` ( `parent_id` int(11) NOT NULL default ''0'', `id` int(11) NOT NULL auto_increment,
2007 Nov 20
2
Plugin: create instance methods dynamically in ClassMethods?
Hi all I have the following plugin code: module IncenseCrud def self.included(base_class) base_class.extend(ClassMethods) end module ClassMethods def performs_incense_crud def index list return render(:action => ''list'') end end end end In init.rb I have the following: require File.dirname(__FILE__) +
2006 Jan 06
0
bug rails activerecord association join
hi, I found a bug in ActiveRecord association SQL INNER JOIN codes. in has_many, has_one, habtm and belongs_to queries the foreign key is determined from the table name of reflection and self. but that''s worng because if you use a global prefix or suffix for your tables the foreign keys will be in format of PREFIX_CLASSNAME_SUFFIX_id which is wrong, because it breaks the advantage of
2006 May 17
2
ActiveRecord::Associations ER diagram/macros
Hello, I found an interesting ER diagram on the "Module: ActiveRecord::Associations::ClassMethods" page of the Rails Framework Documentation : http://ar.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html At the beginning we can read ? Associations are a set of macro-like class methods for tying objects together through foreign keys. They express relationships like
2004 Nov 30
1
RE: question about rails regarding handling more than onetable in one view
Hi, Jarkko: Thanks for the quick reply. I understand I can use ActiveRecord to specify the relation between the table as you have suggested, The part that I have trouble to understand is 1. Since I have a third table ProvWorkAtDept, do I need to specify this table somewhere when I define Provider or Dept? 2. If the provider view has both the provider name and several depts the provider
2006 Jan 04
1
Multiple Associations With The Same Object
I have a Company object which has multiple Contacts (has_many/belongs_to) I would like one of the contacts to be the primary contact. What''s the best way to do this? Right now I have: create table companies ( id int not null auto_increment, name varchar(50) not null, primary_id int null, constraint fk_company_primary_contact foreign key (primary_id) references contacts(id),
2006 Apr 06
4
using two foreign keys to the same table
i am working on a task manager with ruby on rails. it is my first major project, so i''m still gettng my feet wet as i learn. i''ve been trying to use the built in relationships to link my tables together, but i''m not able to use the same naming conventions. for each task, it has a field for the creator, and another field for the assignee. both of these fields
2006 May 17
10
HABTM << producing incorrect insert sql ?
Greetings railsers - I''m trying to add to a collection through HABTM, but the sql insert is trying to insert a PK rather than letting mysql produce the auto_increment''ed PK. ## @medication_dose holds a validated, saved model @medication_dose.medication_frequencies << MedicationFrequency.find (:all) The above bails with, Mysql::Error: #23000Duplicate
2005 Mar 01
1
rename associations
Greetings all, In looking at the API for ActiveRecord::Associations::ClassMethods there doesn''t appear to be a way to rename an association. In doing some refactoring I am replacing one table with two but want to preserve the old associations names, e.g. I want to be able to still say build_type.artifacts instead of having to use the new table name: build_type.build_type_artifacts.
2006 Jun 03
1
Can I tell if the associated record is new in a belongs_to save?
In a belongs_to association, is there a way to tell if the associated object was newly created? Hopefully this will explain my question: A Firm class declares has_many<http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000530>:clients and a client class declares
2005 Dec 12
2
count sql failing with unknown table....
Hey Rails People, I''m doing my first Rails app and I''m having a newbie problem with the count method.... Mysql::Error: #42S02Unknown table ''jobs_sectors'' in where clause: SELECT COUNT(*) FROM jobs WHERE (jobs_sectors.sector_id = 1 ) Extracted source (around line #4): 1: <div class="sectors"> 2: <ul> 3: <% for sector in @sectors
2005 Mar 10
10
Some Basic Questions
Sorry I can''t access IRC from work so I hope you don''t mind me asking my newbie questions here: 1) I have the following code: @post = Post.find(@params[''id'']) @comments = Comment.find_all "post_id = #@params[''id'']", "created_on ASC" And I am have problems with the second line. I want to pass the id from my post to the
2006 Jun 28
0
ActiveRecord mapping users to icons
In a simple webapp containing users and user icons, what''s the right way to use ActiveRecord to store these objects and then designate a single ''primary'' icon for each user, given: - a set of users. - for each user, zero or more icons they''ve uploaded (tied to their account). - for each user, zero or one icon from their set of uploaded icons designated as
2008 Apr 11
1
polymorphic associations wrong when used with inherited class?
Consider the following: class Event belongs_to :event_object, :polymorphic => true end class Asset < ActiveRecord::Base end class EventedAsset < Asset has_one :event, :as => :event_object end EventedAsset.find(:first).event generates the following SQL: SELECT * FROM `events` WHERE (events.event_object_id = 1 AND events.event_object_type = ''Asset'') LIMIT 1
2006 Jan 10
5
Noob ActiveRecord Join Question
I''m new to rails and ruby, and after trying to get this to work correctly for hours, I thought I''d give this forum an try. I''ve setup a trivial project just to mess around with Rails database naming conventions and associations. I''ve got a table called Pets, and a table called Types. Pets contains a list of pets, Parky the cat, Daisy the dog, etc, And Types
2005 Dec 15
8
How to ensure deletes cascade to associated models?
I have the following models: class Resume belongs_to :resume_assignments end class User belongs_to :resume_assignments end class ResumeAssignment has_one :resume has_one :user end When I delete a resume, I want to make sure that its associated ResumeAssignment gets deleted also. Calling destroy_all to delete some resumes doesn''t seem to do this. Is there an option that will
2006 Jan 13
1
association callbacks
Hello all. I am looking for some feedback on an implementation. I''m writing a plugin that will log all model changes. I do not want to have to add a line a code for this functionality every time I create a model. Instead I create a table with the name <model>_changes. The basic stuff was easy: base.after_create {|model| model.log_create if model.has_backup_table?
2006 Jul 19
2
Creating a safe sequence generator
Hi all, I''ve got a rails and database question. Accounts have jobs, and job numbers should be assigned per account. Account 89 should have jobs 1-whatever, which are not the same as account 67, which has jobs 1-whatever. In the past, I have accomplished this quite easily with: create table job ( accountid int(10) unsigned not null default 0, jobid int(10) unsigned not null