[Rails] Re: A second production environment

2010-05-14 Thread Ben Woodcroft
Ar Chron wrote: > First simple question: > > Have you compared the log files for those two environments? Is your > second "production" environment really being treated as production? > > Sounds like you're getting all the dev class reloading and logging, just > like a non-production environmen

[Rails] A second production environment

2010-05-13 Thread Ben Woodcroft
Hi, I'm attempting to create a second production environment, because I have multiple databases to maintain, and production is much faster. So now I have 2 'production style' environments, called 'production' and 'apiloc_production' To create the apiloc_production environment, I added a new entry

[Rails] Re: Multiple Joins to a single table

2010-04-28 Thread Ben Woodcroft
Sharagoz wrote: > If you just want to use activerecord without writing inner joins > manually you can do > @decks_with_aces = Deck.all(:joins => :cards, :conditions => > "cards.rank = ''Ace") > @decks_with_kings = Deck.all(:joins => :cards, :conditions => > "cards.rank = ''King") > @decks_with_aces

[Rails] Re: Multiple Joins to a single table

2010-04-28 Thread Ben Woodcroft
Marnen Laibow-Koser wrote: > Sharagoz wrote: >> Since you are going to join the same table twice, you might as well >> write the whole SQL manually. ActiveRecord doesnt allow you to do >> something like :joins => [:cards as 'c1', :cards as 'c2']. > > Except that it does, since :joins can take a st

[Rails] Re: Multiple Joins to a single table

2010-04-28 Thread Ben Woodcroft
Sharagoz wrote: > Since you are going to join the same table twice, you might as well > write the whole SQL manually. ActiveRecord doesnt allow you to do > something like :joins => [:cards as 'c1', :cards as 'c2']. ok. That's not a very satisfying answer but it is good to be confident that I'm no

[Rails] Re: Multiple Joins to a single table

2010-04-28 Thread Ben Woodcroft
Dani Dani wrote: > Oh, does it mean deck is a table ? if so, I think the following > association will help you further: > > class Card < ActiveRecord::Base > has_many :coolcards > has_many :deck, :through => :manifests > end > > class CoolCards < ActiveRecord::Base > belongs_to :card > belon

[Rails] Re: Re: Multiple Joins to a single table

2010-04-28 Thread Ben Woodcroft
Dhruva Sagar wrote: > Hi Ben, > > m_id = Materials.first(:conditions => "name == 'cardboard'") > > Deck.all(:joins => 'inner join cards on cards.deck_id = cards.id', > :conditions => ["(cards.name = 'Ace' OR cards.name = 'King') AND > cards.material_id=?", m_id]) > > How about that ? I don't th

[Rails] Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Dani Dani wrote: > Question. wouldn't the following do the work ? > > Card.find(:all, :conditions => "rank='Ace' or rank='King'" ).each do > |card| > decks << card > > or am I missing here something ? > > Dani Thanks for the response - appreciated. Well, I'm looking for a single query to be s

[Rails] Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
So one problem I've run into is that I cannot join beyond the table that has been joined twice, without excessive amounts of SQL. For instance, if there is a materials table (cards are made out of some material) - Material < ActiveRecord::Base has_many :cards end --

[Rails] Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Dhruva Sagar wrote: > Hope it worked :). Yes, it did, and now I have named scopes working nicely, like named_scope :with_card(rank) in the Deck class, and I can even chain them together. Bob Miller wrote: > > now that eh? -- Posted via http://www.ruby-forum.com/. -- You received this mes

[Rails] Re: Re: Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Dhruva Sagar wrote: > Sorry it should be : > > Deck.all(:joins => 'inner join cards c1 on c1.deck_id=decks.id > inner > join cards c2 on c2.deck_id=decks.id ', :conditions => > ["c1.rank = 'Ace' AND c2.rank = 'King']) Thanks for persevering - that's what I was after. I

[Rails] Re: Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Dhruva Sagar wrote: > Hi, > > Can't your sql be : > > select * from decks d > inner join cards c1 on c1.deck_id=d.id > where > c1.rank = 'Ace' and > c1.rank = 'King'; Unfortunately I don't think so. c1 cannot be both an ace and a king at the same time. I just tested your code on a rails setup w

[Rails] Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Sharagoz wrote: > @decks_with_aces_and_kings = Deck.all(:joins => :cards, :conditions => > "cards.rank = 'Ace' OR cards.rank = 'King'") Looks good, except it seems my question wasn't clear (even to me re-reading it). I want decks that have kings and aces, so an OR isn't what I'm looking for. Any

[Rails] Re: Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Dhruva Sagar wrote: > Yes, > > class Deck < ActiveRecord::Base > has_many :cards > has_many :cool_cards, :through => :cards > end Thanks for the help Dhruva, but doesn't that mean that there is a cool_cards foreign key in the cards cards table? I don't quite understand how this helps - what q

[Rails] Multiple Joins to a single table

2010-04-27 Thread Ben Woodcroft
Hi, Is it possible to join multiple times to the same table with ActiveRecord? For instance: - class Deck < ActiveRecord::Base has_many :cards end class Card < ActiveRecord::Base end - And then I run a query for decks that contain ac

[Rails] Re: regular expression problem

2010-04-27 Thread Ben Woodcroft
HUNT HUNT wrote: > var text="Afganistan (+86)" > var code=text.sub(/\w+/, '') > result: code = (+86) > -- > > var text = "Antigua and Barbuda (+1268)" > var code=text.sub(/\w+/, '') > result : code = and Barbuda (+1268)" > > -- > wh

[Rails] Re: Page caching when name contains a dot (period)

2010-04-14 Thread Ben Woodcroft
Dave Silvester wrote: > So, the workaround for this is to (assuming all the pages that are being > cached should be served as text/html) make a .htaccess file with the > following line in it, and put it in the same directory as the > problematic > cached files: > > ForceType text/html > > That s