Displaying 20 results from an estimated 1000 matches similar to: "Inheritance via Though Associations?"
2006 Apr 02
0
STI and through
I''m trying to understand how to do the following, but am finding myself stuck.
I have three main tables; here are the first two:
CREATE TABLE reference_items (
"id" integer primary key,
"type" varchar(20),
"title" varchar(255),
"year" year(4)
);
CREATE TABLE "agents" (
"id" integer primary key,
"type"
2005 Dec 10
0
Paginate - Count(*) Broken or Am I Cheating?
I have the following paginator setup:
@merch_pages, @merch = paginate :merch_item, :per_page => 15, :select =>
''DISTINCT mi.id, mi.merch_image, mi.created_at, mi.artist_id,
mi.item_description, art.sort_name'', :join => ''as mi JOIN merch_formats mf
ON mi.id = mf.merch_item_id JOIN artists art ON mi.artist_id = art.id'',
:order =>
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 =>
2006 Jun 19
3
Strange behavior of :through association.
class Host < ActiveRecord::Base
belongs_to :person
end
class House < ActiveRecord::Base
has_many :people, :dependent => true
has_many :hosts, :through => :person
end
class Person < ActiveRecord::Base
belongs_to :house
has_many :hosts, :dependent => true
end
Now when I try to do:
@hosts = House.find_by_id(params[:namas]).hosts
from my controller I get this:
2005 Apr 20
4
acts_as_list and single table inheritance
in a single table inheritance model, rails will automatically set the
scope for acts_as_list to the ''type'' field as well as any other scope
conditions we provide.
Is there a way to disable this? i want to use STI but I want
acts_as_list to disregard the class type when getting/setting
positions.
thanks
alan
2006 Sep 03
7
using polymorphic associations with acts_as_list
This is what I have
class Photo < ActiveRecord::Base
belongs_to :image, :polymorphic => true
acts_as_list :scope => image
end
class Place < ActiveRecord::Base
has_many :photos, :as => :image
end
class Child < ActiveRecord::Base
has_many :photos, :as => :image
end
I want to be able to reorder the images. What I need is for the
position of the photos to be set
2006 May 16
0
Possible bug: ActiveRecord::Base::has_many fails for String arguments.
Hi
I''ve noticed ActiveRecord::Base::has_many fails for String arguments.
The following code works when all arguments to the
ActiveRecord::Base::has_many calls are Symbols:
class Country < ActiveRecord::Base
has_many :country_products, :dependent => true
has_many :products, :through => :country_products
end
ruby script/console
>> Country.find_all.first.products
2006 Jul 10
10
has_many :through and foreign key parameters
I just took my HABTM and turned it into a :through since my join table
has another "non-joiny" attribute.
I went from this:
has_many_and_belongs_to :jobs, :join_table => ''tablename'',
:foreign_key => ''x'',
:association_foreign_key => ''y''
to this:
has_many :jobs, :through =>
2008 Jul 23
0
Link_to_remote object missing
Hello, I''m in troubles trying to use ''link_to_remote'' on Rails 2.1.
Having this page:
<h4>Editing project</h4>
<% form_for(:project, :url => project_path(@project), :html =>
{ :method => :put }) do |f| %>
<p>
Name <%= f.text_field :name %>
Date <%= calendar_date_select :project, :target_date, :time =>
2008 Feb 22
7
undefined local variable or method "acts_as_list"?
Hi, I''m getting the error below, and I''m not sure where to find
"acts_as_list" ...
NameError in SpecialsController#printer
undefined local variable or method `acts_as_list'' for #<Class:
0xb7a46994>
RAILS_ROOT: /usr/local/apache2/htdocs/dps
Application Trace | Framework Trace | Full Trace
vendor/plugins/trunk/lib/scope_out.rb:70:in
2009 Jan 04
3
undefined local variable or method `acts_as_list'
So I seem to be having an issue with trying to install acts_as_list in
rails 2.2.2?
I have downloaded the files from: http://github.com/rails/acts_as_list/tree/master
I have put the files in the vendor/plugins folder the files are as
follows:
vendor/plugins/acts_as_list/init.rb
vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
vendor/plugins/acts_as_list/test/list_test.rb
2006 May 26
6
Help needed with acts_as_list
Hi ! There must be something I don''t understand clearly in acts_as_list
I have a list of gallery entries (images + text), model is GalleryEntry.
I have a field in_exhibition (boolean)
I want the list to be sorted with a scope on in_exhibition : from 1 to N
for every record having in_exhibition = false and 1 to N for every
record having in_exhibition = true
When I use acts_as_list
2007 May 22
3
can I use acts_as_list with a has_many :through association
I''d like to be able to use a has_many :through association and treat
the associations as a list but I''m getting this error when I try an
use an acts_as_list method:
NoMethodError: undefined method `move_to_bottom''
I''m using edge rails r6786.
Here are my domain rules:
Activities are things students can do.
Units consists of a sequenced list of
2007 Aug 15
3
ActsAsList specs
Hi,
How are people specifying models which act_as_list?
I''m thinking that it would be possible to check that acts_as_list
instance methods have been added to a class using something like this:
describe Page, "acts_as_list" do
it "should act as a list" do
Page.ancestors.should be_include(ActiveRecord::Acts::List::InstanceMethods)
end
it "should use
2007 May 15
4
Way to mark record as main?
I was curious if there was a built in feature in ActiveRecord or a
plugin, but I basically have a database for phone numbers. I want a user
to be able to make a phone number as main. There can only be one phone
number marked as main at all times. Is there something for this?
Thanks for your help.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
2005 Nov 25
2
acts_as_list with 2 fields in the scope
Hi Railers,
I''ve got a Categories table.
I want it to act as a list within the scope of the parent_id AND the
site_id.
Categories table :
id
label
site_id
parent_id
So, in my Category class, I have :
acts_as_list :scope => ''site_id = #{site_id} AND parent_id = #
{parent_id}''
The problem is that when I try to move_up a Category with a parent_id
that is null,
2007 Nov 24
12
orphan habtm rows
HI,
i use models User and Groups connected with many to many association, so
i have users table, groups and groups_users.
lets say i create one user and one group. next i add a group to user. so
now my table groups_users has one entry i.e.
group_id | user_id
_________|________
1 | 1
ok, when i delete both my group and user, above entry is not deleted,
thus leaving alone without
2006 Apr 07
6
Magic Field Names - "position"
What does the Magic Field Name position do?
I was looking here:
http://wiki.rubyonrails.com/rails/pages/MagicFieldNames
And unfortunately that documentation is incomplete.
Thanks.
--
Posted via http://www.ruby-forum.com/.
2009 Jan 05
3
Plugin not found: ["acts_as_list"]
I am trying to install acts_as_list in a rails 2.2.2 project but when I
try the following: ruby script/plugin install acts_as_list
I get: Plugin not found: ["acts_as_list"]
I had to download the acts_as_list plugin from the github because it
isn''t included in Rails 2.2.2.
The files are in my vendor/plugins/acts_as_list folder so I have:
lib/active_record/acts/list.rb
2010 Dec 22
8
Shoulda issue: no more "should have_instance_methods" ?
I''m using Shoulda.
After copying the code here....
.... http://joshuaclayton.github.com/code/2009/07/14/should-act-as-list.html....
into my test_helper file so I can test acts_as_list, I came across
issues. For one I realized I had to get rid of the _ between the
"should" and "have" in past cases, but here, I get this error when I
run my unit test: