Hi, It seems like the content of my lib folder no longer is reloaded automatically. I need to restart the WEBrick server after a file has been modified. Someone know how to prevent caching in this directory? I''m running rails 0.14.3.2969 Thanks, regards and peace! -- Posted via http://www.ruby-forum.com/.
I believe only classes decended from Rails classes (such as ActiveRecord::Base) reload automagically. I don't know if there is a way to make other classes reload, I'd love to know too. Jacob On 11/29/05, Kåre <okiik@hotmail.com> wrote:> Hi, > > It seems like the content of my lib folder no longer is reloaded > automatically. I need to restart the WEBrick server after a file has > been modified. Someone know how to prevent caching in this directory? > I'm running rails 0.14.3.2969 > > Thanks, regards and peace! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I have a many to many relationship for two tables (topics and groups) and a
join table for the two tables (groups_topics)
I have code working where I can access all the topics for a group by
group.topic, which returns an array of topic instances. This works fine.
The problem is that there might be 1000s of topics valid for a particular
group. One use case I have is I just want to see if one specific topic is
valid for a group. Using the above, I''d have to iterate the array to
find
this out. It seems like there should be a faster way where I can leverage a
condition ("topic_name=blah") instead of returning/iterating a huge
result
set.
I saw a blurb in the agile rails book on this subject, but it didn''t
give
enough detail for me to understand....
Can someone point me in the right direction?
Thanks,
phil
I believe that''s what require_dependency ''foo'' does. It reloads the required file on each request but only in development mode. -Ezra On Nov 29, 2005, at 7:53 PM, Jacob Quinn Shenker wrote:> I believe only classes decended from Rails classes (such as > ActiveRecord::Base) reload automagically. I don''t know if there is a > way to make other classes reload, I''d love to know too. > > Jacob > > On 11/29/05, Kåre <okiik-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> Hi, >> >> It seems like the content of my lib folder no longer is reloaded >> automatically. I need to restart the WEBrick server after a file has >> been modified. Someone know how to prevent caching in this directory? >> I''m running rails 0.14.3.2969 >> >> Thanks, regards and peace! >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Thanks Erra for the response. I have asked this exact question a while back but got no answers... -- Posted via http://www.ruby-forum.com/.
how do you differentiate between a non-valid group and a valid group? On 11/29/05, Phil Swenson <phil-XITSOACK58NFw/DY4jzso32qnSAIaJbt@public.gmane.org> wrote:> > I have a many to many relationship for two tables (topics and groups) and > a > join table for the two tables (groups_topics) > > I have code working where I can access all the topics for a group by > group.topic, which returns an array of topic instances. This works fine. > > The problem is that there might be 1000s of topics valid for a particular > group. One use case I have is I just want to see if one specific topic is > valid for a group. Using the above, I''d have to iterate the array to find > this out. It seems like there should be a faster way where I can leverage > a > condition ("topic_name=blah") instead of returning/iterating a huge result > set. > > I saw a blurb in the agile rails book on this subject, but it didn''t give > enough detail for me to understand.... > > Can someone point me in the right direction? > > Thanks, > phil > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
There is another table for users.. So I find the correct User instance and
then use "user.group" to get the correct instance of Group
I''ve read that one approach is to create a model for the join table
groups_topics. but I have no clue how to proceed from there.
Any help on this stuff would be greatly appreciated!
phil
_____
From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On
Behalf Of Chris Hall
Sent: Wednesday, November 30, 2005 7:46 AM
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails] active record question
how do you differentiate between a non-valid group and a valid group?
On 11/29/05, Phil Swenson
<phil-XITSOACK58NFw/DY4jzso32qnSAIaJbt@public.gmane.org> wrote:
I have a many to many relationship for two tables (topics and groups) and a
join table for the two tables (groups_topics)
I have code working where I can access all the topics for a group by
group.topic, which returns an array of topic instances. This works fine.
The problem is that there might be 1000s of topics valid for a particular
group. One use case I have is I just want to see if one specific topic is
valid for a group. Using the above, I''d have to iterate the array to
find
this out. It seems like there should be a faster way where I can leverage a
condition ("topic_name=blah") instead of returning/iterating a huge
result
set.
I saw a blurb in the agile rails book on this subject, but it didn''t
give
enough detail for me to understand....
Can someone point me in the right direction?
Thanks,
phil
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
ah, i misread... given an arbitrary topic, you want to see if its associated with a group... easy. arbitrary_topic = Topic.find(1234) group = Group.find(1, :include => :topics) # find out if arbitrary topic is associated with group # if group.topics.include?(arbitrary_topic) # found the topic in the group else # did not find topic in group end On 11/29/05, Phil Swenson <phil-XITSOACK58NFw/DY4jzso32qnSAIaJbt@public.gmane.org> wrote:> > I have a many to many relationship for two tables (topics and groups) and > a > join table for the two tables (groups_topics) > > I have code working where I can access all the topics for a group by > group.topic, which returns an array of topic instances. This works fine. > > The problem is that there might be 1000s of topics valid for a particular > group. One use case I have is I just want to see if one specific topic is > valid for a group. Using the above, I''d have to iterate the array to find > this out. It seems like there should be a faster way where I can leverage > a > condition ("topic_name=blah") instead of returning/iterating a huge result > set. > > I saw a blurb in the agile rails book on this subject, but it didn''t give > enough detail for me to understand.... > > Can someone point me in the right direction? > > Thanks, > phil > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
i suppose you could even do group = Group.find(1) topic = group.topics.find(1234) documentation doesn''t specify what is returned from find so it could be a RecordNotFound exception or nil if the record does not exist. On 11/30/05, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > ah, i misread... > > given an arbitrary topic, you want to see if its associated with a > group... > > easy. > > arbitrary_topic = Topic.find(1234) > group = Group.find(1, :include => :topics) > > # find out if arbitrary topic is associated with group > # > if group.topics.include?(arbitrary_topic) > # found the topic in the group > else > # did not find topic in group > end > > > > On 11/29/05, Phil Swenson <phil-XITSOACK58NFw/DY4jzso32qnSAIaJbt@public.gmane.org> wrote: > > > > I have a many to many relationship for two tables (topics and groups) > > and a > > join table for the two tables (groups_topics) > > > > I have code working where I can access all the topics for a group by > > group.topic, which returns an array of topic instances. This works > > fine. > > > > The problem is that there might be 1000s of topics valid for a > > particular > > group. One use case I have is I just want to see if one specific topic > > is > > valid for a group. Using the above, I''d have to iterate the array to > > find > > this out. It seems like there should be a faster way where I can > > leverage a > > condition ("topic_name=blah") instead of returning/iterating a huge > > result > > set. > > > > I saw a blurb in the agile rails book on this subject, but it didn''t > > give > > enough detail for me to understand.... > > > > Can someone point me in the right direction? > > > > Thanks, > > phil > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
This is helping..getting further.
I tried this:
group.topic.find(:first, :conditions=>[ "symbol=?",
"LM"])
and get:
ActiveRecord::RecordNotFound: Couldn''t find Topic with ID in
(''---
:first'',''--- \n:conditions: \n - \"symbol=?\"\n -
L
M'')
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/associa
tions/has_and_belongs_to_many_a
ssociation.rb:77:in `find''
from (irb):112
from :0
"symbol" is a column in the "Topics" table
Not sure why though???
_____
From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On
Behalf Of Chris Hall
Sent: Wednesday, November 30, 2005 8:02 AM
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails] active record question
i suppose you could even do
group = Group.find(1)
topic = group.topics.find(1234)
documentation doesn''t specify what is returned from find so it could be
a
RecordNotFound exception or nil if the record does not exist.
On 11/30/05, Chris Hall
<christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote:
ah, i misread...
given an arbitrary topic, you want to see if its associated with a group...
easy.
arbitrary_topic = Topic.find(1234)
group = Group.find(1, :include => :topics)
# find out if arbitrary topic is associated with group
#
if group.topics.include?(arbitrary_topic)
# found the topic in the group
else
# did not find topic in group
end
On 11/29/05, Phil Swenson <
phil-XITSOACK58NFw/DY4jzso32qnSAIaJbt@public.gmane.org
<mailto:phil-XITSOACK58NFw/DY4jzso32qnSAIaJbt@public.gmane.org> >
wrote:
I have a many to many relationship for two tables (topics and groups) and a
join table for the two tables (groups_topics)
I have code working where I can access all the topics for a group by
group.topic, which returns an array of topic instances. This works fine.
The problem is that there might be 1000s of topics valid for a particular
group. One use case I have is I just want to see if one specific topic is
valid for a group. Using the above, I''d have to iterate the array to
find
this out. It seems like there should be a faster way where I can leverage a
condition ("topic_name=blah") instead of returning/iterating a huge
result
set.
I saw a blurb in the agile rails book on this subject, but it didn''t
give
enough detail for me to understand....
Can someone point me in the right direction?
Thanks,
phil
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
that's because find() for a habtm only works on the id column, as in my
example.
what you probably want is
topic = group.topics.detect { |t| t.symbol == "LM" }
On 11/30/05, Phil Swenson <phil@collectiveintellect.com>
wrote:>
> This is helping….getting further…
>
>
>
> I tried this:
>
>
>
> group.topic.find(:first, :conditions=>[ "symbol=?",
"LM"])
>
>
>
> and get:
>
>
>
> ActiveRecord::RecordNotFound: Couldn't find Topic with ID in ('---
> :first','--- \n:conditions: \n - \"symbol=?\"\n - L
>
> M')
>
> from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1
> /lib/active_record/associations/has_and_belongs_to_many_a
>
> ssociation.rb:77:in `find'
>
> from (irb):112
>
> from :0
>
>
>
> "symbol" is a column in the "Topics" table
>
>
>
> Not sure why though???
>
>
> ------------------------------
>
> *From:* rails-bounces@lists.rubyonrails.org [mailto:
> rails-bounces@lists.rubyonrails.org] *On Behalf Of *Chris Hall
> *Sent:* Wednesday, November 30, 2005 8:02 AM
> *To:* rails@lists.rubyonrails.org
> *Subject:* Re: [Rails] active record question
>
>
>
> i suppose you could even do
>
> group = Group.find(1)
> topic = group.topics.find(1234)
>
> documentation doesn't specify what is returned from find so it could be
a
> RecordNotFound exception or nil if the record does not exist.
>
> On 11/30/05, *Chris Hall* <christopher.k.hall@gmail.com > wrote:
>
> ah, i misread...
>
> given an arbitrary topic, you want to see if its associated with a
> group...
>
> easy.
>
> arbitrary_topic = Topic.find(1234)
> group = Group.find(1, :include => :topics)
>
> # find out if arbitrary topic is associated with group
> #
> if group.topics.include?(arbitrary_topic)
> # found the topic in the group
> else
> # did not find topic in group
> end
>
>
> On 11/29/05, *Phil Swenson* < phil@collectiveintellect.com> wrote:
>
> I have a many to many relationship for two tables (topics and groups) and
> a
> join table for the two tables (groups_topics)
>
> I have code working where I can access all the topics for a group by
> group.topic, which returns an array of topic instances. This works fine.
>
> The problem is that there might be 1000s of topics valid for a particular
> group. One use case I have is I just want to see if one specific topic is
> valid for a group. Using the above, I'd have to iterate the array to
find
>
> this out. It seems like there should be a faster way where I can leverage
> a
> condition ("topic_name=blah") instead of returning/iterating a
huge result
> set.
>
> I saw a blurb in the agile rails book on this subject, but it didn't
give
> enough detail for me to understand....
>
> Can someone point me in the right direction?
>
> Thanks,
> phil
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/30/05, Phil Swenson <phil@collectiveintellect.com> wrote:> There is another table for users…. So I find the correct User instance and > then use "user.group" to get the correct instance of Group > > I've read that one approach is to create a model for the join table > groups_topics… but I have no clue how to proceed from there… > > Any help on this stuff would be greatly appreciated! > > phil > > ________________________________ > > > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of > Chris Hall > Sent: Wednesday, November 30, 2005 7:46 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] active record question > > how do you differentiate between a non-valid group and a valid group? > > On 11/29/05, Phil Swenson <phil@collectiveintellect.com> wrote: > > I have a many to many relationship for two tables (topics and groups) and a > join table for the two tables (groups_topics) > > I have code working where I can access all the topics for a group by > group.topic, which returns an array of topic instances. This works fine. > > The problem is that there might be 1000s of topics valid for a particular > group. One use case I have is I just want to see if one specific topic is > valid for a group. Using the above, I'd have to iterate the array to find > this out. It seems like there should be a faster way where I can leverage > a > condition ("topic_name=blah") instead of returning/iterating a huge result > set.You could try: topic.groups.find(group_id) Or, you could try: group.topics.find(topic_id) Both examples assume that you have has_and_belongs_to_many setup correctly. Iteration to check on a relation is completely nonsensical. If the method you need is not available, you still have the complete, expressive power of SQL at your disposal.> Can someone point me in the right direction?I'm not sure if this is the right direction for you, but I hope it helps, - Rowan -- Morality is usually taught by the immoral. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails