Displaying 20 results from an estimated 6000 matches similar to: "Eager loading wierdness"
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 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
2007 Jan 20
2
Conditional pluralize without the number
Hi.
Assume you have an array of person names. I want to generate results in
my view that look like this:
Abby is your friend
or
Abby, Bob, and Carol are your friends.
So I''d like to say:
<%= friends.to_sentence %>
<%= pluralize(friends.count, "is") %>
your <%= pluralize(friends.count, "friend") %>
But because pluralize puts in the
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.
2007 Dec 07
2
[ActiveSupport] Patches needing review: re-organization of #to_query methods, preservation of XML/JSON content-type
Just a quick pointer to some ActiveSupport patches hoping for reviews:
Puts Array#to_query and Object#to_query in the right places in
ActiveSupport - http://dev.rubyonrails.org/ticket/10395
Preserve user-specified content type for XML and JSON rendering
(currently it''s overridden and set to Mime::XML/Mimi::JSON -
http://dev.rubyonrails.org/ticket/10388
Oh and a tiny patch for
2006 Aug 09
2
Link to most recent
Greetings all,
I have a side panel in my app that needs to have a link to the most recent 4
or 5 items in a table. How do I create this link?
For example, I have a controller named widgets, and I want to create a link
to :controller => "widgets", :action => "show", and then the most recent id.
I want the text link to be the name of the widget.
Any ideas? Obviously,
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 Jun 12
0
Rails Testing Strategies
As part of an application I am developing, I have been delving into the
dark art of Rails testing. Since the existing literature on the topic
is a bit sparse, I have written up a couple of brief articles on testing
strategies for rails.
The first one is on the usefulness of ''Positive and Negative Controls'',
and the other is a simple way to make sure you are working with
2007 Oct 08
1
Can you alias fields in acts_as_ferret?
Is there any way to set a field name that is different than the method
name used to populate it?
My example:
In Rails, I''m using acts_as_ferret on a Article model that has_many
Authors. I want to be able to index authors'' names with each article.
Since @article.authors yields an array of Author objects (and not an
indexable string), I''ve created this method in my
2008 Mar 02
2
check_box_tag remote_function
I have a collection of check_box_tags that look like the following:
<% for item in @items %>
<%= check_box_tag "item[item_ids][]", item.id, false, {:onchange =>
remote_function(:url => update_items_path, :with => "''items='' +
escape(value) "} %>
<%= item.name %>
<% end %>
My question is, how do I send all of the current
2006 Jul 28
1
How to ajax highlight a flash
Hi,
I want to make a flash[] highlighted for let''s say 5 seconds when some
action is invoked.
In the controller, I have:
flash[:notice] = "error"
In the layout, I have:
<p style="color: white"><%= flash[:notice] %></p>
I don''t know how to use ajax with the flash. I tried something like:
element.highlight(flash[:notice])
without any
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
2013 Jan 25
3
how to delete the null elements in list
HI,
I have the list:
> suu
[[1]]
NULL
[[2]]
NULL
[[3]]
item_id prod
1 2
[[4]]
item_id prod
1 2
2 4
how to delete all "NULL" elements from suu to get only
>suu
[[3]]
item_id prod
1 2
[[4]]
item_id prod
1 2
2 4
??
Kind regards,
Tammy
[[alternative HTML version deleted]]
2006 Jul 17
3
Best practices - field initialization based on display rules
All,
I have a form with the following field interaction rules.
Given checkbox A,
text field B
text field C
If checkbox A is checked then make text field C equal to the value of
text field B and disable field C.
If checkbox A is unchecked then enable field C.
In order to display a form where I''m manipulating an already existing
object, I have something like this in my RHTML template
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/.
2008 Jan 04
1
eager loading and polymorphic associations
There is a dedicated section about eager loading in the docs. A
coworker discovered eager loading does not work in polymorphic
associations the hard way :-) so I''ve written a patch that documents it:
http://dev.rubyonrails.org/ticket/10610
There are at least a couple of tickets that implement something that
would change that though:
http://dev.rubyonrails.org/ticket/9640
2006 Jun 28
4
Load IDs For Limited Eager Loading
Hi
Trying to cut down on queries with eager loading and noticed the
following in development.log
Load IDs For Limited Eager Loading - SELECT id ....etc
Followed by
Load Including Associations - SELECT table.id ... etc
Is this common practice? What is limted eager loading?
Cheers
Mark
--
Posted via http://www.ruby-forum.com/.
2006 Mar 31
2
Eager loading of polymorphic associations
Polymorphic associations work great until I try to do some eager
loading through :include. In my example, the interface name is
":imagehaver". Here''s my little eagerly loading find line:
Image.find(params[:id], :include => :imagehaver)
All it gives me is an ActiveRecord::EagerLoadPolymorphicError with no
further explanation. I haven''t been able to dig up anything
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
2010 Oct 25
1
A few fixes to eager loading issues
Hey all,
I''d really appreciate some eyes on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5845-activerecord-3-eager-loading-fail#ticket-5845-19. There''s a small issue in Rails 3 eager loading, and this ticket has an accompanying patch.
Sssociations that show up twice in a Relation chain like:
Article.includes(:comments).includes(:comments =>