Displaying 20 results from an estimated 10000 matches similar to: "Rails Testing Strategies"
2006 Aug 07
1
Eager loading wierdness
Consider this problem.
I have an Item that has_many Features
I want to find all Items with a Feature name of ''foo''.
Normally you would do this..
@items = Item.find(:all, :conditions=>["features.name = ?", ''foo''],
:include=>:features)
This all works fine and dandy except for this problem.
If you do this...
<% for item in @items %>
2006 Aug 02
5
Fun with ez_where
I''ve been trying to use the ez_where plugin to create a dynamic finder.
The structure looks somehing like this..
=== controller ===
def list
attribute_filter = params[:filter]
@filter = Caboose::EZ::Condition.new :table do
attribute <=> attribute_filter if attribute_filter
end
#
... do the find with the @filter
#
end
=== view ===
....
<%= link_to
2006 May 24
0
polymorphic url and polymorphic partial helpers
Here are a couple of articles I wrote describing a couple of handy
helpers for dealing with polymorphic objects.
These helpers allow you to generate urls and render partials on objects
without knowing what class they are ahead of time.
http://www.sciwerks.com/blog/2006/05/24/polymorphic-urls/
http://www.sciwerks.com/blog/2006/05/24/polymorphic-partials/
Hopefully you will find them useful.
2006 Aug 07
0
multi-state check boxes
Has anyone tried to create a tri-state or multi-state checkbox control
for rails?
What I''m looking for is a control that will cycle through a series of
states when clicked. Like ''No'' -> ''Maybe'' -> ''Yes'' -> ''No'' ....
_Kevin
www.sciwerks.com
--
Posted with http://DevLists.com. Sign up and save your
2006 Mar 09
4
Testing Migrations
Is there some standard way to test migrations?
It seems to me that an additional safeguard for migrations would be to
test and see if applying the migrations to the test database allows one
to reconstruct the structure of the development database.
If you can''t, then there is an error in your migrations, most likely
because someone hand-modified the database without generating a
2006 Jul 15
12
Safe way to destroy records
Hello,
how can I check if a destroy was successful?
Is the object only frozen if deleted or do I have to do an additional
find to see if there is a record left?
What happens if an after_destroy callback returns false? Is there always
a rollback?
Markus
2006 May 24
3
using a helper from the console
I''ve got a couple of helper functions in my application_helper file that
I would like to run from the console (for debugging).
What is the correct way to invoke a helper from the console?
_Kevin
--
Posted with http://DevLists.com. Sign up and save your mailbox.
2006 Jul 07
3
dynamically updating a listbox from another listbox
Hi,
I would like to be able to dynamically (without reloading the page)
change the values from one listbox when a user select items from another
listbox. I have a model ''Sector'' which has_many ''levels'' (and of cours,
''Level'' beyong_to ''sector''). I want to show the user two listboxes with
the sectors and levels. But
2006 Feb 08
3
RJS templates before, during and after
RJS templates are nifty. They let you put all sorts of fun effects all
over your bland html pages without too much work.
The link_to_remote function also lets you run scripts before, during,
and after an AJAX call is run by using callbacks.
There does not seem to be an equivalent method for running an RJS
template before or during an action. Rendering it at the end is no problem.
One
2006 Jun 02
2
Group checkbox toggling
This isn''t really a scriptaculous question, but it might be interesting
anyway.
I''m generating a rails app and in one form I have a grid of check-boxes
(rows = A..H and col=1..12).
I would like to put a checkbox in the column/row headers to toggle the
boxes in a particular row or column. Each box has a name like
''position_A1'' or
2006 Jul 15
13
Active Record: Can it auto-create database tables for you?
Hi,
Just get started with Rails and I''m trying to read ahead and find out
whether Active Record supports auto-creation of database tables for you?
Is this supported, or is the concept that you write your own database
DDL to do this?
Thanks
--
Posted via http://www.ruby-forum.com/.
2006 May 04
12
RJSCallback 0.1
Announcing RJSCallback 0.1
The RJS Callback plugin is being developed to provide Ruby On Rails with
the ability to easily call RJS templates for the various callbacks
associated with AJAX function calls (e.g., :before, :loading, :complete).
Currently this plugin automatically detects, loads, and renders RJS
templates with specific names and inserts them in the appropriate spot
in
2006 Jul 26
4
Dropdown with concatenated columns.
What is the best way to create a drop down where the viewable text in a
concatenation of 2 or more columns?
For instance, I hane a lookup table with these columns.
Model FOO
columns: id , name, phone
In my drop select tag, I''d like the user to see:
"name1 phone1"
"name2 phone2"
etc..
I know I can do this using find_by_sql . ..
But, isn''t there a more
2006 Feb 21
4
Multi-page forms
I''m curious to see how others are dealing with the construction of
multi-page forms. I can see a couple of ways to do this, each with
their own advantages/disadvantates.
Approach 1:
* define one table with columns for each form entry.
* define a method/view for each page, which only displays a subset of
the fields.
* submitting a page saves the data and moves on to the next page.
2006 Jul 20
9
Including children''s children?
a has many b''s
b has many c''s
results = A.find params[:id], :include => :b
How do you also make sure the b''s include the c''s?
Thanks for your help.
Thank You,
Ben Johnson
E: bjohnson@contuitive.com
O: 800-341-6826
M: 817-229-4258
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 May 21
2
acts_as_taggable and single table inheritance
I''ve set up a couple of STI models like such that we get something like
this...
class A < AR:Base
class B < A
acts_as_taggable
class C < A
acst_as_taggable
(using the acts_as_taggable plugin)
I can tag things just fine this way, the problem I encounter is that the
taggings are listed with the base class ("A") and not the appropriate
subclass ("B"
2006 Aug 02
4
Search function in this Forum ??
This forum has been a great resource for me. It would be great if i can
search the forum before posting any question, as i''m sure someone has
already posted that question before. The search function has been
disabled for quite sometime now. I''ve already emailed the administrator
but haven''t got any response.
any idea on when this would be enabled ?
Thanks,
VASU.
2006 Jul 20
3
sort_by with via a parent models child
I am having a problem with ruby''s sort_by function. I want to sort a
list of parent model objects based on the children of the parent models.
Normally you might say sortedList = modelList.sort_by { |model|
model[''someAttribute''] }
What I am tring to do is
sortedList = modelList.sort_by{ |model| model.children.find(:first,
order=>"price desc" ).price}
2006 Jul 24
3
HowTo?: Eager caching of third order ActiveRecord assoc.
Hello.
Using the ":include", which generates a "LEFT OUTER JOIN" SQL command,
it is possible to eagerly preload second order data objects (children)
for a given association.
I wanted to know, if it is possible to eagerly preload and cache
third order (or more) data objects, which are little-children or
little-little-children. As I''ve seen. it is possible to add
2006 Feb 08
3
Using shared RJS templates
I''ve got an action in my application controller that needs to call a
shared RJS template. Typically it''s actually being called by subclasses
of the application controller.
I''ve tried this..
def action
...code..
render :partial => "shared/template"
end
with ''_template.rjs'' existing in the shared folder.
The problem that crops