similar to: has_and_belongs_to_many and dynamic find

Displaying 20 results from an estimated 2000 matches similar to: "has_and_belongs_to_many and dynamic find"

2010 Oct 11
8
Nooby Stuck - "has_and_belongs_to_many" relationship
trying to set up a "has_and_belongs_to_many" relationship would very much appreciate the help, not sure what im doing wrong at all. Scheme.rb class Scheme < ActiveRecord::Base validates :schemename, :presence => true belongs_to :user has_many :levels, :dependent => :destroy has_and_belongs_to_many :works end Work.rb class Work < ActiveRecord::Base
2007 Jul 17
5
habtm confusion
Hello friends! I am trying to make a database that will have a group of people set to committees, and a person can be in multiple committees, and a committee obviously has multiple people. The people are senators at my university. These are my current models: senator.rb: -- class Senator < ActiveRecord::Base validates_presence_of :first_name, :last_name, :floor has_and_belongs_to_many
2010 Sep 01
0
Error on update_attributes with HABTM relationship
Hope someone can tell me what''s up, because this has me baffled. I have an Image model, and a Provider model. Both are defined as "has_and_belongs_to_many" relating to each other. In my image form partial, I have a bit of AJAX generating the provider_ids array dynamically from a provider AJAX search on the same page. So for example, each time I click on a provider name that
2006 Jan 23
0
type mismatch because of misled array index
Most times I look up a list of books I want to know a page reference for each one, so the views that display booklists expect an array of two-element arrays, constructed via a method in the model like so: (class Category) def book @book = Array.new self.bookshelves.each { |x| @book << [x.book, x.pages] } return @book end When I get the list of all books that a user has
2009 Nov 17
5
has_many :through and foo.bars.include?
hallo everybody, i already googled the following problem, but there are so many questions regarding "has_many :through", that i just couldn''t find what i was looking for. so, i''m really sorry if this has been asked before. if so, just drop me the link. i have a has_many :through relationship similar to the following example: class Group < ActiveRecord::Base
2006 Mar 20
2
AHHHhhhhh... has_and_belongs_to_many, that is going on?
I don''t have a class by the name of "ReviewersScoreCard", yet my many to many configuration looks as follows. And, these errors while running some simple test with ./script/console is giving me a headache: ./script/console Loading development environment. >> r = Reviewer.find_first => #<Reviewer:0x19d0a48 @attributes={"id"=>"1",
2008 Jul 13
2
Problem with ActiveRecord::AssociationTypeMismatch
Hi all ! I''ve written a Character model, each character has many Attributes. My schema.rb looks like this: create_table "characters", :force => true do |t| t.string "first_name" t.string "last_name" t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" end create_table "attributes",
2010 Jan 26
2
accepts_nested_attributes_for :has_many :through => 'bug?'
Hey guys & ladies! I''ve got the following relationship which i''m trying to get accepts_nested_attributes to work with. But when i submit my form, it looks as if its expecting a Company object, rather than an array of companies. which really doesn''t make sense considering its a has_many :relationship. So what i''m after, is a way to
2006 Nov 09
2
help with join tables and has_and_belongs_to_many
Hi, I have a user model and a privilege model. They have the has_and_belongs_to_many relationship. Here are the model defs: class User < ActiveRecord::Base belongs_to :status has_and_belongs_to_many :privileges end class Privilege < ActiveRecord::Base has_and_belongs_to_many :users end Now I have a migration script to create the join table and populate a few users with some
2006 Apr 04
1
habtm and options_from_collection_for_select [1.0.0]
I ran into a problem using options_from_collection_for_select : ActiveRecord::AssociationTypeMismatch (Topic expected, got String): /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/ active_record/associations/association_collection.rb:128:in `raise_on_type_mismatch'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
2006 Aug 08
1
File upload into Mysql (using lighttpd) problem
Hello All, I''ve run into a snag. (I apologize in advance. I''m not very good at system administration.) I''m building an app that allows users to upload files. Up until now I have been storing the files on the file system, but tonight I decided to change the app so the files are stored in the database as a longblob. I thought everything was working great, until I
2010 Aug 19
1
has_many :through question
I am trying to create an association table using the ":through" option in "has_many" but not having success. I have created the necessary migrations of the association tables and run rake db:migrate I have the following model: class Group < ActiveRecord::Base has_many :users, :through => :group_user has_many :invites, :through => :group_invite, :class_name =>
2007 May 28
1
upload_column problems on post after validation error
Hi to all the crew ! I''ve a little (big ?) problem. I''m using upload_column plugin, it works very well but it throws an exception when I try to repost the form after a validation error. Here some details: Model: (hostel.rb) HOSTEL_PHOTO_DIR = Proc.new {|inst, attr| "hostel/#{inst.id}"} HOSTEL_PHOTO_THUMB = "100x100" HOSTEL_PHOTO_NORMAL =
2007 Aug 15
2
has_many :through ... What am I missing?
class Ladder < ActiveRecord::Base has_many :players has_many :users, :through => :players end class Player < ActiveRecord::Base belongs_to :users belongs_to :ladders end class User < ActiveRecord::Base has_many :players has_many :ladders, :through => :players end When I try the following code (on the console) I get an error: @ladder = Ladder.find(1) @ladder.users I
2007 Dec 04
10
ActiveRecord::AssociationTypeMismatch
I have the requirement to empty the association records and add the association records as new (as below). @task = Task.find(params[:task_id]) @task.task_users = [] params[:ids].split(", ").each do |court_user_id| task_user = TaskUser.new(:court_user_id => court_user_id) @task.task_users << task_user end @task.save This is not working. Following error is thrown.
2008 May 16
0
attachment_fu and/or rmagick on osx -- weird error
One of our developers is getting a weird error from attachment_fu and/or rmagick on OSX. And even weirder because he''s used attachment_fu and rmagick on other projects without difficulty. This all works fine on debian/ubuntu. See the stack trace below. Any suggestions? Btw, the code that''s blowing up is retrieving the attachment_fu info. The presence of image_science in
2008 Nov 06
10
Rails 2.1.2 bug in include on has_many?
In my continued efforts to port my rails 1.x app to Rails 2.1.2, I keep running into what appear to be ActiveRecord bugs. I am using an :include on a :has_many definition: class Request < ActiveRecord::Base has_many :service_types, :order=>''service_types.id ASC'', :include=>:service_response [...] There''s no reason this wouldn''t be supported in
2005 Dec 11
4
Problem with acts_as_paranoid: "ArgumentError: Unknown key(s): group"
Here''s the full error: 1) Error: test_add_message_to_existing_ticket(TicketTest): ArgumentError: Unknown key(s): group /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.4/lib/active_support/core_ext/hash/keys.rb:48:in `assert_valid_keys'' /usr/lib/ruby/gems/1.8/gems/acts_as_paranoid-0.2/lib/acts_as_paranoid.rb:125:in `validate_find_options''
2006 Dec 22
2
Relating Namespaced Models
I am dealing with a large project. I use a lot of STI and therfore have a lot of models. I''d like to use namespaces to help organize my models but am having trouble getting started. I have a base model Term::Base located in /app/models/term/base.rb: class Term::Base < ActiveRecord::Base set_table_name "terms" end I have a non-namespaced client model: class Client <
2007 Jul 04
5
stack level too deep
Hi, I have a SystemStackError. Here is the stack (sorry if it''s a little long) : app/models/line_item.rb:14:in `product'' app/models/line_item.rb:14:in `product'' app/controllers/store_controller.rb:188:in `redirect_to_paypal'' /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/association_proxy .rb:123:in `each''