Displaying 20 results from an estimated 1000 matches similar to: "Reloading and redefining methods: infinite recursion"
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 Oct 05
0
Database querying for synthetic attributes?
For some queries it is complicated to express them directly in SQL. Even
more so when they are not hand-written, but generated from something
the user entered. Say, the user wants to search for person records
where the name contains some string. Now, while the Rails model may
have a name attribute, the database table does not. There the name is
decomposed into title, firstname, lastname and
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
2008 Jun 05
2
how to add a method without coding it directly into app?
i''m missing something here.
how would I code this outside the application to be shared with other
Camping apps?
module Blog::Controllers
module AuthenticationHelper
def self.included(base)
class << base
define_method :authenticate do |*a|
a.each do |meth|
if method_defined?(meth.to_s)
2005 Aug 19
13
Enumerations (again): Comments please
Some of my earlier questions may have hinted ever so slightly in the
direction that I''m trying to implement "enumerations". By an
enumeration here I mean a class that has a fixed number of immutable
instances, which in turn have essentially only a name and a position.
Requirements I''ve tried to meet are
- Enumeration instances should only be loaded once from the
2005 Dec 31
6
habtm recursion via destroy_without_callbacks
I am having a problem with two models that each have a HABTM
relationship to the other. For example:
CREATE TABLE people (id INT, name TEXT);
CREATE TABLE teams (id INT, name TEXT);
CREATE TABLE people_teams (person_id INT, team_id INT);
The person model has:
has_and_belongs_to_many :teams
And the team model has:
has_and_belongs_to_many :people
The trouble comes when trying to destroy
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|
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 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 =>
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
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 Sep 06
1
US Date Handling in Rails
My application is built on Rails and MySQL. It will only be accepting US
formatted dates as input, however both Rails and MySQL are oriented around
ISO the format. I know I can convert a good portion of the entries using
ParseDate::parsedate but it does not appear this is how the conversion is
taking place when data is being transferred from the params hash into model
members.
Say I have a field
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