Displaying 20 results from an estimated 4000 matches similar to: "how to use scope with acts_as_list"
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 30
2
acts_as_tree, acts_as_list and is invincible (help!)
So I have the following model
class Topic < ActiveRecord::Base
belongs_to :topic
has_many :topics, :order => :position
acts_as_tree :order => :position
acts_as_list :scope => :topic_id
end
that I use for a site''s navigation. Everything (list, create, edit, even
the drag&drop sort) works fine, except the destroy function, which the
vanilla version
def destroy
2007 Nov 14
1
has_many_polymorphs and acts_as_list ?
First, BRAVO for this wonderful plugin: has_many_polymorphs ! Now my
problem:
4 models : Collection, Page, Fragment, Belonging (which is the join
table):
1 class Collection <
ActiveRecord::Base
2 has_many_polymorphs :elements,
3 :through => :belongings,
4 :from => [:pages, :fragments, :collections],
5 :as => :collector,
6 :parent_order =>
2006 May 15
0
acts_as_list, move_higher, odd indexing behaviour?
Hi,
[reposting to list, posting via google groups apparently didn''t work]
I''m trying to use acts_as_list for the first time.
Can anyone confirm the odd behaviour reported here?
http://blog.nominet.org.uk/tech/Web/2006/03/06/Using_acts_as_list_in_...
i.e. element access and move_higher require an odd indexing scheme to
work.
I''m personally finding that I
2006 Apr 20
1
Rails is losing key information
I am using ruby 1.8.4 with rails 1.0 under fedora core 3 on a WIntel
platform.
Rails appears to be losing key information under some circumstances.
Specifically, in the Questions class that follows, the presentation_id
property is apparently being lost.
The STDOUT dump from the create method indicates that the
presentation_id should be 42, but the dump from the database shows that
it is 43,
2006 Jan 10
0
bug? : STI and :include => fk and class_name MUST be specified
I suspect this is a bug. Or a limitation.
Problem:
----------------
When you include a STI class in a ''find'' :
@results = Result.find :all, :include => :event
, you are forced to specify the fk and the class name :
belongs_to :event , :class_name => "Event", :foreign_key =>
"event_id"
.
Full code:
-----------
class Event <
2005 Mar 01
0
has_and_belongs_to_many problem
I''m having a problem with a has_and_belongs_to_many (habtm)
association between two models with extra attributes. I''m writing a
comic book database, and each issue has many creators on it. Thing
is, some creators perform multiple duties. They may write one issue,
draw another, etc.
However, if I add a creator twice to an issue and try to delete it, it
removes both creators:
2006 Mar 28
1
Rails generates query with reserved word for field name
For some reason, rails is generating this SQL:
SELECT FIRST 1 * FROM questions WHERE (parent_id IS NULL) ORDER BY
position DESC
1. There is no column named position referenced in my code.
2. POSITION is a reserved word in SQL92. It is the name of a string
function that returns the offset of one string within another. I
believe that this is a bug in Rails. Either position should be
2006 Jun 11
0
Reaching through a belongs_to for acts_as_list scope?
I''m running into a situation where I''d like to provide the list scope
for an acts_as_list model from one step removed. In minimalistic form
(with several other associations removed from each level).
class MainEntity < AcrtiveRecord::Base
has_many :containers
end
class Container < ActiveRecord::Base
has_many :elements
belongs_to :main_entity
end
class
2006 Apr 01
0
Okay, what gives? find_by_id is failing.
This has the look of a "just don''t quite get it yet" problem. I am
using the ActiveRecord.find_by_id method to identify the parent object
(Quiz) to tie to the child object (Question) at create time.
Here is the stdout log:
127.0.0.1 - - [31/Mar/2006:22:43:22 CST] "GET /question/new?
parent_quiz=ff2d7022-be0a-11da-9f01-00400506faf5 HTTP/1.1" 200 806
2007 Mar 28
1
acts_as_list nested scope
Here''s what I''m trying to do:
class Model < AR::Base
acts_as_list :scope => [:key_one_id, :key_two_id, :key_three_id]
end
with the idea being that there are these three references from this table
(one of them being optional) that define the list. I don''t think acts as
nested set works in this situation because I''m still just dealing with a
single list
2006 Apr 21
0
acts_as_list with the scope on boolean field
I have a boolean field in mysql (tinyint) which I want to use as a
scope restriction for acts_as_list
acts_as_list :scope => ''featured = #{featured}''
however, there is a problem here as when Rails generates SQL query for
this it supplements true/false for #{featured} which raises error in
mysql
As a workaround I created dummy attributes that return 1/0 depending
on featured
2006 Apr 01
3
acts_as_list with scope : position update problem?
Hello,
I''ve tried to set up a class with acts_as_list with a scope argument
that restricts a list to records with the same foreign key.
For example :
database :
CREATE TABLE `families` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '''',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
INSERT INTO
2006 May 21
3
acts_as_list scope and polymorphic association.
this is my model:
class Person < ActiveRecord::Base
has_many :phones, :as => :callable, :order => :position
end
class Phone < ActiveRecord::Base
belongs_to :callable, :polymorphic => true
acts_as_list :scope => :callable_id
end
how can i add the callable_type to the scope.
how can i say the scope is the {:callable_id,:callable_type} couple?
is it even possible?
thanks
2006 Mar 15
1
Through method problems with custom foreign_keys
A person has a many company_branches and
A company_branch has many people.
This join is represented using a "contacts" table.
I am using a legacy schema so i am forced into using non-standard rails
primary keys. I am using the new through relationship in rails 1.1.
p=Person.find(1)
b=p.company_branches # gives this error:
ActiveRecord::StatementInvalid: OCIError: ORA-00904:
2006 Mar 31
3
Complex Through Statement
Quick Overview:
I have an ''Employee'', some ''Merchants'' and some ''Products''. A
''Merchant'' has many ''Products''. An ''Employee'' has multiple ''Merchants'',
depending on their relationship. For example, the Employee may be the
enrollment contact for one merchant and the
2007 Apr 29
1
acts_as_list with :scope - how do I move items to a different list?
Hi,
I have in my simplistic app:
class Album
has_many :pics, :order => :position
end
class Pic
belongs_to :album
acts_as_list :scope => ::album
end
It all works fine when creating a new pic from the forms. But, when
trying to move a pic between albums, the album changes Ok, but no
matter what I do the position attribute stays the same and the list
navigation is broken. So far,
2006 Jan 20
11
Userstamp Plugin
I''m pleased to announce a new plugin for Rails: Userstamp. You can read my
blog post at http://www.delynnberry.com/articles/2006/01/20/userstamp-plugin
and/or read all about it at the perminant page
http://www.delynnberry.com/pages/userstamp. Any comments or suggestions for
improvement are much appreciated.
--
DeLynn Berry
delynn@gmail.com
http://www.delynnberry.com
A dump of the Readme
2006 Mar 29
3
Self-referential many-many joins with :through
I thought I had this nailed but.. now I''m seeing spots..
I''ve included my models below, feel free to ignore them. I''m really
just after an example that works. I couldnt find one on the wiki...
which is fair enough considering Ricks patch:
http://dev.rubyonrails.org/changeset/4022 that fixed them only went
through 5 days ago..
Cheers
-henster
2009 Apr 16
0
Magic multi connections with association problem
Dear all
I am using magic multi connections, there is some problem when using
association. How can I dynamic determine the module name (i.e.
A::Request, B::Request) in activerecord association.
Below is my code:
module A
establish_connection :A
end
module B
establish_connection :B
end
# and many module....
class Request < ActiveRecord::Base
set_table_name "request"