Displaying 20 results from an estimated 4000 matches similar to: "Database querying for synthetic attributes?"
2005 Aug 05
0
Finding by inclusion in nested set
Say I have tasks with a belongs_to association to categories where the
later act as a nested set. Now I want to find all tasks belonging to a
specific category (given as primary key) or any of its sub-categories.
SELECT tasks.*, tasks_category.name
FROM
categories AS nested_set_categories, tasks
LEFT OUTER JOIN
categories AS tasks_category
ON
tasks_category.id = tasks.category_id
WHERE
2005 Sep 17
0
Reloading and redefining methods: infinite recursion
When I redefine a method like this
class Klass
alias_method :method_without_addition, :method
def method_with_addition
...
method_without_addition
...
end
alias_method :method, :method_with_addition
end
I get into trouble in the development environment. As these definitions
are executed again for each request, the second time around
method_without_addition is actually the
2005 Sep 13
3
Alternatives to Rico LiveGrid?
I''m no friend of paging, but I have to somehow deal with lists of
potentially large numbers of objects. The Rico LiveGrid[*] at first
blush seems attractive, but has some major drawbacks. It doesn''t work
with Safari/Konqueror, not yet anyway. It can only handle fixed-size
tables and requires that widths, including column widths, are
hand-crafted.
I''m looking for a
2005 Sep 06
4
url_for: :overwrite_params went missing
Somewhere between 0.13.1 and the current SVN version
the :overwrite_params option to url_for (and related methods) went
missing. I can''t tell whether this was deliberate or by mistake, and I
have no idea how to get the same functionality in some other way
either.
Michael
--
Michael Schuerig Life is what happens
2005 Oct 09
1
Setting the user for FastCGI processes?
I''d like to run the FastCGI as a different user than the Apache2 server
(www-data on Debian). I take it this is possible in some way with
suExec2, but so far I haven''t figured out how to do it.
Michael
--
Michael Schuerig Life is just as deadly
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org As it looks
2005 Aug 16
1
Defining model classes for enumerations
I have several tables for enumerations. They all have the same content:
id, name, position. I''d like to avoid the tedious work of defining a
class for each one explicitly. Not least, in order to avoid clutter in
the model directory.
Here''s what I''ve come up with:
class EnumRecord < ActiveRecord::Base
def self.define_enums(*enums)
enums.each do |spec|
2008 Apr 29
4
Default values for belongs_to and has_one
There really doesn''t seem to be a *declarative* way to define a default
value for belongs_to and has_one associations
class Person < ActiveRecord::Base
belongs_to :address
end
p = Person.new
p.address.city = ''Atlantis'' # Bummer!
Of course, there''s an easy way to avoid this
class Person < ActiveRecord::Base
belongs_to :address
2007 Jan 03
3
Self-referential habtm with condition is broken
Here''s a simplistic model class.
class Person < ActiveRecord::Base
has_and_belongs_to_many :relatives,
:class_name => ''Person'', :join_table => ''relatives'',
:foreign_key => ''from_id'', :association_foreign_key => ''to_id''
has_and_belongs_to_many :brothers,
:class_name =>
2009 May 12
4
has_many :through and scopes: how to mutate the set of associated objects?
I have a model layer containing Movie, Person, Role, and RoleType,
making it possible to express facts such as "Clint Easterbunny is
director of the movie Gran Milano".
The relevant model and associations look like this
class Movie < ActiveRecord::Base
has_many :roles, :include => :role_type, :dependent => :destroy
has_many :participants, :through => :roles, :source
2005 Aug 28
8
Save and delete buttons: POST vs. proximity dilemma
I''m in a dilemma: In order to keep GET requests from deleting objects,
I''d like to use the button_to helper to get "something" that generates
a POST request. Unfortunately, that something is a form and forms can''t
be nested.
I''d also like to place buttons related to the same form close to each
other. At the top are some navigational buttons
2007 Jan 11
2
In-place editor for a whole form?
I want to implement in-place editing for a hierarchical structure where
the nodes are not simple text fields, but need to be represented by at
least two input elements.
The Rails helpers only support in-place editing for a text field,
scriptaculous''s controls.js beyond that implements support for an
in-place editor containing a select element. I need an editor where I
essentially
2005 Sep 13
12
PDF views?
I know there''s wiki page on generating PDF[*], but that''s not really
what I want. I don''t need to create arbitrary PDF. What I''d like to do
is create PDF templates and fill in the blanks. Roughly, I''m looking
for functionality akin to the mail merge feature of word processors,
including conditional and repeated elements, say, table rows.
Michael
2005 Oct 18
0
Munging the class attribute: Benchmarks anyone?
In prototype/scriptaculous there are currently two different approaches
to munging the class attribute of HTML elements. Scriptaculous has
Element.Class which recently moved from util.js into effects.js.
Prototype has Element.ClassNames and several convenience functions
around it.
In the past I''ve grown fond of Element.Class, but I''m perfectly willing
to use
2010 Jun 20
0
ActiveRecord and ARel: correlated subqueries?
I''m trying to figure out how to use ActiveRecord in conjunction with
ARel. In particular, I''d like to replace my residual literal SQL with
ARel, if only I could see how.
Let''s take Article with multiple Versions as an example. With ARel
alone, I can find articles with their latest versions like this
articles = Article.arel_table
versions = Article.arel_table
2005 May 27
0
tag, content_tag: are nil-valued options ever useful?
In a number of places in my code I pass options whose value are '''' or
nil to one of the tag-generation helper methods. In the HTML this shows
up as, e.g.
<span class="">
Now, this can be pretty wasteful, but I don''t want to change my evil
ways. Thus I''d rather have the framework throw out these options than
do it myself. AFAICT, all tag
2005 Aug 23
0
Fixtures: pluraly bitten
With my functional tests (on PgSQL) I get strange errors like this
1) Error:
test_create(AufgabeControllerTest):
ActiveRecord::StatementInvalid: ERROR: duplicate key violates unique
constraint "aufgaben_pkey"
Tracking this down, I found that sequences are only reset for some of
the tables I''m using. The reason? Inconsistent singularization.
I won''t go so far as
2005 Apr 23
0
collection_select: generated select tag not marked on error
When a select tag generated by collection_select has a validation error
the tag isn''t marked in the page. That is, the generated tag looks like
this, say,
<select id="obj_attrib_id" name="obj[attrib_id]">
<option value="1">Option 1</option>
<option value="2">Option 1</option>
</select>
Whereas is should,
2008 Jan 21
1
JavaScript book recommendations
No, not a question, but a few suggestions.
I take it that everyone serious about using Prototype & Co. already has
Christophe''s (Porteneuve) Prototype and Script.aculo.us book. Apart
from that, I''d like to point out two new, library-agnostic books:
Cameron Adams and several others
The Art & Science of JavaScript
Sitepoint 2008
http://www.sitepoint.com/books/jsdesign1/
2005 Nov 24
1
Extended $ function called $$
This code lets you use standard CSS selectors to get an array of elements.
For example, $$("#container div.myElements") would return all subelements of
#container that are divs and are of the class myElements.
I submitted similar code a while back to the email address for the prototype
library but never got a reply. Thought I''d post this in the hopes that some
others will find
2010 Jun 20
0
Debugging a Rails 3 app with RadRails 2?
When trying to debug a Rails 3 app with RadRails 2.0.4, I''m running into
a problem with gem loading, apparently. See below for a stack trace.
That problem disappears, when I move Gemfile out of the way, but, of
course, then other necessary gems aren''t loaded.
From my Debug Configuration
Project: <myproject>
File: script/rails
Working Directory: