similar to: Plugin belongs_to Model Association Bug

Displaying 20 results from an estimated 20000 matches similar to: "Plugin belongs_to Model Association Bug"

2006 Feb 27
4
2 belongs_to to the same parent table
Hello! I have 2 table: users and buddies User: id, name, ... Buddy: id, user_id, user_buddy_id, ... So if you have 2 users 1,jack and 2,fred and fred is a buddy of jack, there is a Buddy object: id=1, user_id=1, user_buddy_id=2 I can declare only one belongs_to in Buddy and one has_many in User. And there is conflict if I had the second one (the first one is discarded) class User has_many
2005 Dec 29
2
has_many & belongs_to with Plugins (login_engine)
Hello list, Probably a newbie question but couldn''t find the answer in the archives. I am using the login_engine Plugin to implement the login functionality. I have a JournalEntry model that interacts with the journal_entries table. I would like to link the journal entries to the user who entered it. Essentially, it is a one to many relationship between the model User(from
2010 Aug 10
2
undefined method `has_many' for Object:Class +Savage Beast 2.3 plugin
Hi, i am using Savage Beast 2.3 plugin for the forum and i got and error undefined method `has_many'' for Object:Class C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb: 9:in `included'' C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb: 7:in `class_eval'' C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb: 7:in
2012 Jan 18
2
Polymorphic and standard association issue
Hello all, I''m having a strange issue with a model that belongs_to two other models. The one association is polymorphic and the other is normal. ================================ class Role < ActiveRecord::Base belongs_to :user belongs_to :permission, :polymorphic => true end class User < ActiveRecord::Base has_many :roles has_many :programs, :through => :roles end
2009 Feb 19
1
ActiveRecord-2.2.2, association preloading, joins and order parameter weirdness
Hello RoR Groupies, I''m seeing some weird ActiveRecord-2.2.2 SQL generation when doing eager association/preloading and using joins and ordering by said join table. Here''s an example: class Photo < ActiveRecord::Base end class User < ActiveRecord::Base has_one :headshot, :class_name => "Photo" end class Mail < ActiveRecord::Base belongs_to :user end
2008 Apr 18
3
has_many and belongs_to with non-primary foreign keys
Hi, I''m having a bit of trouble with my first Rails app. ---- I have two tables: create_table :items do |t| t.column :created_at, :timestamp t.column :user_id, :int t.column :text, :text end create_table :users do |t| t.column :user_id, :int t.column :name, :string end ---- I''m trying to use the "user_id" field to link both tables, with each user
2006 May 10
3
has_many association.
I''m creating a address book. A user can have many contacts. In the user model, I put: has_many :contacts And in the contact model, I put: belongs_to :user To list all contacts, I search as following: @user = User.find(session[:user_id]) And rendering: <%= render(:partial => "contact", :collection => @user.contacts)%> To persist I am using the following
2006 Jul 08
1
conditional table association?
I''m using a db to log two types of events, link events and tag events. At first I had two tables, link_events & tag_events, but this seemed not very DRY because the only column that was different between them was link_id and tag_id respectively. So I made these tables: events: id int user_id int objtype_id int (holds ''1'' or ''2'' depending
2011 Jan 11
0
[PATCH] Polymorphic belongs_to association with :conditions issues
Hey all, Could use a few eyes on a couple of very simple patches at https://rails.lighthouseapp.com/projects/8994/tickets/6262 if any has some time. The issue (from the ticket description): If you define a polymorphic belongs_to association and it has conditions on it, those conditions cause a NameError when you try to access the target object, of the style saying "hey, there''s no
2005 Dec 23
2
has_many and belongs_to relationship error
Hi i am getting following error ActiveRecord::StatementInvalid in Blog#index Showing app/views/blog/index.rhtml where line #10 raised: Mysql::Error: #42S22Unknown column ''posts.user_id'' in ''where clause'': SELECT * FROM posts WHERE (posts.user_id = 4) Extracted source (around line #10): 7: <div class="separator">&nbsp;</div> 8:
2006 May 05
0
Missing documentation for find_in_collection? Trying to drill down in a 4 level has_many association fails
I''ve been reading up in ActiveRecord::Associations and playing around with my app via the console and found some interesting methods via the code completion of IRB, but I have no idea how to use them and can only find one hint in the API http://api.rubyonrails.com/classes/ActiveRecord/Associations/ ClassMethods.html It mentions here in the has many associations that if you use the
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
2006 Jul 31
0
Polymorphic has_many association through a belongs_to
Hi, Let''s say I''ve the following Models and their relative associations: Seat ---- belongs_to :booking Booking ------- has_many :seats has_many :debits, :as => :chargeable Debits ------ belongs_to :chargeable, :polymorphic => true Why >> seat.booking.debits nil while >> Booking.find(seat.booking_id).debits [] ? Thanks. Cheers, Marco
2006 Jul 06
4
has_one, belongs_to - I am just not getting it
Let me preface by saying i''m a total noob at ruby/rails. :-) For some reason, I am just not grasping the concept of has_one & belongs_to... I''m working on a project that includes user authentication, and 3 different types of user profiles. User profiles are either "fan", "band", or "venue" objects, and user logins are "user"
2006 Mar 31
6
Adding objects to a :through association
So I''m one of those nasty people building a self-referential habtm-like Association using the funky new :through stuff. This is about users having friends, so here''s my user.rb: class User < ActiveRecord::Base has_many :friendships, :foreign_key => ''user_id'' has_many :friends, :through => :friendships, :source => :friend end And here''s
2009 Aug 10
1
Call AR belongs_to association accessor ID method on object assignment
Hi, Haven''t been able to find this raised before but I''m sure it must have been. When assigning an object to a belongs_to association I would like it to call the *association*_id= method instead of directly updating the attributes array. This is because I want to modify the behaviour when assigning a particular object without writing separate methods for whether it''s
2008 May 07
1
Assigning to the foreign key on a belongs_to association
I''ve encountered what seems like an odd omission in the behaviour of belongs_to associations: if you assign to the foreign key attribute, it doesn''t update the associated object (or mark a previously loaded one as stale) until you explicitly save or reload it. Let''s say we have a Company model, which belongs_to :city : >> torchbox =
2010 Jun 29
3
belongs_to. Association methods don't pass data to DB
Hi. I have a problem with the association methods which passed to a model through a belongs_to declaration. Here''s an illustration of the issue: GIVEN: # migration class CreateArticlesAndAuthorsTables < ActiveRecord::Migration   def self.up     create_table :articles do |t|       t.text     :title       t.integer :author_id     end     create_table :authors do |t|       t.text
2014 Apr 19
0
How to has_one/belongs_to association only return the objects unassociated in combobox?
I have two models (Car and Driver) and a combobox to select which driver belongs to which car. I want the combobox just show the objects that have not yet been associated. # vehicle belongs_to: driver # driver has_one: vehicle # simple_form # vehicle/_form.html.haml = f.association: driver, label_method: :name, value_method: :id How to ensure validation before saving, to avoid problems of
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