Displaying 20 results from an estimated 20000 matches similar to: "Re: STI and Joins Broken"
2006 Aug 23
2
Re: STI and Joins Broken
I''ve made a inheritance rework some weeks ago that would possible fix
it since it only loads the inheritance support in the class that''ll use
it.
In STI case, it would load only if the class that descends directly
from AR has been inherited and the column specified in the
inheritance_column is available.
People here told me to wait until next release so we can dig into this,
but
2006 Sep 03
2
Fwd: Dealing with exec?
---------- Forwarded message ----------
From: Kevin Clark <kevin.clark at gmail.com>
Date: 01-Sep-2006 20:31
Subject: Dealing with exec?
To: James Mead <jamesmead44 at gmail.com>
Hey James,
Sorry to bug you. I was curious how you''d handle a call to exec in a
method you were testing. Kernel.stubs(:exec)... doesn''t seem to work
but I''m not sure where else an
2006 Dec 21
4
Stubbing Kernel#open
Anyone know how to stub Kernel#open? I''m trying to mock/stub an
open-uri call, but it doesn''t seem to like it.
Here''s the test code, and the failures:
body = File.open(File.dirname(__FILE__) +
''/../fixtures/google_search_california.html'').read
2006 Sep 03
1
Returning different values with stubs
Right now I''m working on adding tests to a method that looks like this:
def get_via_redirect(path, args={})
get path, args
follow_redirect! while redirect?
status
end
So, I want to confirm that get is called and that status is returned
but I also want to see that when the value of redirect? effects how
many times follow_redirect is called. Is there
2006 Sep 03
1
Slimmed down version for inclusion in Rails?
I''m pushing a major overhaul in testing the Rails codebase. Mocha and
stubba make my life easy so that''s what I''m using. The first major
patch using them is in RailTies
(http://dev.rubyonrails.org/ticket/5970) now. I spoke to DHH today
about using it in the other libraries and I think it''ll be ok, but
they really want to include as little code as needed. I
2007 Jun 11
12
Mocking system/`
This drives me insane on a regular basis. How does one mock
system(''blah'') or `blah` ?
Adding expectations on Kernel doesn''t do it. Adding expectations on
Object just makes me sad:
Object.any_instance.expects(:system).with(''ls'')
# => #<Mock:0x12b584e>.system(''ls'') - expected calls: 0, actual calls: 1
And this really
2007 Jan 17
8
Mocha Mock''s hanging on after test run?
Hi guys,
I''m running mocha (0.3.2) against Rails core and just found an issue
where the mock doesn''t go away after the test is run.
For example:
def test_reset_bang_doesn_reinstall_named_routes
ActionController::Routing::Routes.named_routes.expects(:install).never
@session.reset!
end
def test_zzz
puts ActionController::Routing::Routes.named_routes.inspect
2006 Sep 03
0
Reducing object polution and mocha?
Hi Kevin,
Not currently, I''m afraid - I always realised it was a possible problem, but
we haven''t run into it in our use of Mocha so far. I guess you''re pushing
the envelope with it, which is great.
If you only need to do it for one or two objects, you could just undefine
the offending methods. In the meantime I''ll look into a better solution. It
may not be
2006 Jul 15
3
How bad is it to have 7 joins in my find_by_sql?
My question is whether there''s a more idiomatic rails way of
structuring this query or of redoing the underlying models. First,
the ugly find_by_sql code, which is the method to generate an atom feed:
def atom
items_per_feed = 15
sql_query = "SELECT activities.*, users.real_name AS real_name,
accounts.last_scraped_at AS last_scraped_at,
2006 Jan 12
5
Question about using DISTINCT in ActiveRecord find method.
Hi,
Am relatively new to the RoR world. My question is quite simple.
I have a query like such:
shipmentNumbers = Order.find_by_sql(["select distinct s.id from orders
o, line_items li, shipment_lines sl, shipments s where o.number=? and
o.id = li.order_id and li.id = sl.line_item_id and sl.shipment_id =
s.id", number])
The above query works fine. I wanted to do the same query using
2007 Apr 12
15
Preview of Latest Mocha Changes
I''ve finally managed to find some time to do some serious work on
Mocha. There are some code snippets on my blog
(http://blog.floehopper.org/articles/2007/04/12/preview-of-latest-mocha-changes)
showing the new functionality available in trunk (revision 128). I
don''t don''t know how many people out there are using trunk, but it
would be great to get some feedback on these
2006 Mar 02
3
Left Joins with Rails?
Everyone,
I have two tables (assuming their most logical types):
apartments
id
address
bedrooms
bathrooms
googlemaps_id
googlemaps
id
url
the models:
class Apartment < ActiveRecord::Base
has_one :googlemap
end
class Googlemap < ActiveRecord::Base
belongs_to :listing
end
I would like to find_all by searching the attributes in apartment, and
also return the google map
2006 Apr 18
3
Join Queries? - find() or find_by_sql()
Hi All,
Is there a way to do join queries with find() or is it best to use
find_by_sql() instead?
I''m looking to do something like:
SELECT winery_name, wine_name FROM winery, wine
WHERE wine.winery_id = winery.winery_id
AND winery.winery_name LIKE ''Borg%'';
Thanks!
: )
Jason
2007 Feb 07
2
Problems Generating Scaffolding
I am having trouble generating some of my scaffolding. I''m trying to
use PostgreSQL as my back-end. Some of my scaffolding generates with
no problem but for other parts I get this:
Before updating scaffolding from new DB schema, try creating a table
for your model
The tables do exist. At least I can see them from psql.
Here is the SQL I''m using to create my tables:
CREATE
2006 Oct 17
4
Mocking the rendering of a Rails template
Hello all,
I''m having difficulty setting up mocks such that I can verify that
Rails was going to render the right template file (for example
new.rhtml) and stop Rails from performing the actual rendering.
After peeking at Rails'' internals, I tried two techniques as illustrated here:
http://pastie.caboo.se/18197
Neither worked.
I think the first one failed because Rails
2007 May 02
2
WHERE NOT syntax with ActiveRecord
I need to run a sql statement along the lines of SELECT * FROM items
WHERE NOT ... But I would like to run this in the ActiveRecord syntax. I
like using :conditions => [...] but obviously where it renders ''WHERE
NOT'' and not simply ''WHERE''. I''d rather not use find_by_sql if at all
possible for security reasons. Anyone know how to do this?
Thanks,
2007 Apr 09
1
help with ActiveRecord joins
I''m working on a fairly complex join query and could use a bit of advice
from more expert users of ActiveRecord.
I have an events table with quite a lot of data, with has_many relations
to categories, age_groups, and event_images. In my first naive
implementation, each event had a date, so to load all upcoming events
efficiently, I''d do:
Event.find(:all,
2006 Jan 30
1
find_by_sql and memcached
Is a find_by_sql query cached with memcached and cached_model
(http://dev.robotcoop.com/Libraries/)? Looks like the answer is no. Is
there a reason for this? I have a lot of very complicated querys with a
lot of unions, subquerys and joins that would greatly benefit from the
cache.
Going through the code I can see that the find_by_sql method is changed
in cached_model.rb, but it does not call
2006 Nov 04
0
Problem with edge rails, controller namespaces and routes
I just upgraded to edge rails so I can use the BigDecimal support for
monetary calculations. I''ve just come across the following problem..
Right now, I''ve got a content controller which is responsible for
updating much of my site''s content. I''ve decided to make this a
subclass of Admin, so I can organize my administrative related
controllers into their own
2006 May 16
0
acts_as_authenticated vs. login_engine
which to use? we''re not doing anyting too fancy, though that may change -- we
might need rbac in the future. i''m using loging_engine right now, pretty
happily, but i came across a blog entry that claims acts_as_authenticated is
the latest and greatest. if anyone has some pros and cons to share, i''d
appreciate it -- would like to make the correct choice before we launch