similar to: Possible bug: ActiveRecord::Base::has_many fails for String arguments.

Displaying 20 results from an estimated 3000 matches similar to: "Possible bug: ActiveRecord::Base::has_many fails for String arguments."

2006 Mar 30
5
Has_many :through problems -- please help
I''m having a lot of trouble with has_many, :through and could really use some assistance. I''ve got a User and Group class. Users can subscribe to groups, and groups should know who''s subscribed. I''ve got a join table (group_subscriptions) with group_id, user_id, and it''s own id element. Users has "has_many :groups, :through =>
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 =>
2006 Jul 21
2
File.open behavior for ActiveRecord, to ensure save after manipulation?
File.open in core Ruby is nifty, in that it automagically closes the file when you''re done using/manipulating it. I''m wondering whether there''s something like that for ActiveRecord? So you can do: AR.find(23).open {|ar| ar.foo = ''bar'' ... } And ar.save would be called when the block closes. -- -Alder
2006 Mar 30
1
strange has_many array problem
I have a class that has_many :visits, I want to search through the visits to get only ones that are committed: I thought it would be as easy as: ================== visits.find_all do |visit| visit.coming? end ================= but this always returns the entire list of visits. The only way to get it to work is to put the visits into a new array first: =================
2006 May 08
2
Creating a "Foo has_many bars" association where bar isn''t a model.
Hi Let''s say we have model Foo. Each Foo instance can have several bars. Those bars are primitive, so they shouldn''t be models. For example, Foo might be a type of convention, and the bars might be years the convention was held in. Naively, we would have a conventions_years date, and put: has_many :years inside class Convention. But then we''d get an error, since for
2006 May 10
2
Exploring ActiveRecord::Base#serialize
Hi I was recently taught about the useful ActiveRecord::Base#serialize. It''s very useful for persisting arbitrary objects through the regular database. For example, say you want to store a Set of all the years a Convention took place. You do: class Convention < ActiveRecord::Base serialize :years, Set end This effectively creates a Convention#years attribute, which is a set: you
2009 Aug 07
2
create separate plots by factors
Hello, I am attempting to create several plots based on "site" (~300 total) and am having trouble with the code. I simply want to create a plot using the code, plot(year, peak), for the following dataset. I would like for each site to be plotted on a separate page and the plots saved in a directory. Would a "foreach" loop work? I tried a "by" statement, but
2006 Jan 24
4
How to filter an activerecord find_all...
I have a nice hierarchical table structure like this: divisions has_many groups groups belongs_to division has_many subgroups subgroups belongs_to group has_many units units belongs_to subgroup I have a report which is based on units, but i want to be able to filter the units by which subgroup, or which group, or which division. I also want to sort them by division.name,then group.name,
2007 Jul 29
1
Curious why this doesn't work. (has_many, belongs_to)
Two Models. class Gm < ActiveRecord::Base belongs_to :pool # mode code here. end class Pool < ActiveRecord::Base has_many :gms # mode code here. end Testing code through the console. >> gm_list.each{ | gm | puts " GM name: #{ gm.user_name } belongs to Pool: #{ gm.pool.pool_name } " }; nil GM name: John belongs to Pool: RHP 07-08 Season - Career League GM name:
2006 May 24
0
ActiveRecord::Base.sanitize_sql and SQL injection vulnerability.
Hi The PostgreSQL development group released an update[1] for PostgreSQL to address a SQL injection vulnerability. From the infromation[2] released with this update, it appears the vulnerability exists in other (all?) database systems allowing multi-byte encoding of requests. Of particular importance - since it relates not to database issues but to web programming practices - are these quotes
2006 Nov 16
2
dynamically adding static (class) methods to a class
Hello again, I guess this is more of a Ruby question, but here goes anyways... I want to intercept all calls to non existent class methods and then call an existing class method with the non existent name. In code... class MyModel < ActiveRecord::Base def MyModel.method_missing(symbol, *args) MyModel.func(symbol.id2name) end def MyModel.func(func_called) puts "You
2005 Dec 27
0
How do I combine :finder_sql and :conditions to perform a sub-search on a custom has_many relationship?
I''m sure there''s something right under my nose that I''m missing. I have two tables with two parallel one-to-many relationships. I wish to use the :finder_sql parameter to essentially ''or'' the two foreign keys. What isn''t working for me is performing a ''sub-search''. Let''s say the tables are "stores" and
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 Aug 11
2
Aliasing a table in ActiveRecord.
Assuming I can''t rename my MySQL tables, how would I modify a model so that it''s called one thing but references a table of a completely different name. For example: class Recipe < ActiveRecord::Base # The actual table is called "FoodInstructions", but I don''t want to use that. end class HomeController < ApplicationController def index
2008 Apr 23
0
self referential (n-n relationship) belongs many controller
Hi all, I ve some troubles in my small acpplication (only 2 tables). I want to follow up tasks but these tasks are linked to others tasks. So I ve tried to do store the nn relationship in other table called links 1st table : tasks columns : id | infos neutral... (as title, description etc ...) ----------------------------------------------------------------------------------- model : class
2005 Dec 27
3
Trouble combining :has_many, :finder_sql and :conditions to create a sub-search
I''m sure there''s something right under my nose that I''m missing. I have two tables with two parallel one-to-many relationships. I wish to use the :finder_sql parameter to essentially ''or'' the two foreign keys. What isn''t working for me is performing a ''sub-search''. Let''s say the tables are "stores" and
2006 Aug 12
7
Collection assignment to a has_many :through
I''m working on a simple photo gallery in rails, it seems to be a good project for a newbie. I have photos and categories, many-to-many association. It worked well with HABTM. Then I decided that it would be good to be able to change order of the photos so that thumbnail pages would look less chaotic. So I created a Layout model which is a join model (or whatever it is called) that
2006 Jun 09
0
Re: Rails Digest, Vol 21, Issue 195
Unsubscribe Sent from my BlackBerry? wireless handheld -----Original Message----- From: rails-request@lists.rubyonrails.org Date: Fri, 9 Jun 2006 18:24:09 To:rails@lists.rubyonrails.org Subject: Rails Digest, Vol 21, Issue 195 Send Rails mailing list submissions to rails@lists.rubyonrails.org To subscribe or unsubscribe via the World Wide Web, visit
2006 Jan 26
3
global objects?
Forgive the term global if that''s not applicable in rails (i come from a php background) I have a browse controller with a couple of different methods def method1 @properties = Property.find_all #other stuff for that method end def method2 @properties = Property.find_all #other stuff for that method end def method3 @properties = Property.find_all #other stuff for that method end I
2006 Jul 09
8
find_all order question
How does one properly get find_all to grab the data from the DB table ordered by a specific column? For example: @anglers = Angler.find_all This code gets all the angler records and they are sorted in order of the id field which is of course set as a primary key in the DB (mysql). I''d really like to pull the data from the DB sorted in the order of another field, for example