Displaying 20 results from an estimated 1000 matches similar to: "Munging the class attribute: Benchmarks anyone?"
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 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
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 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 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 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 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,
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
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/
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:
2006 Aug 14
2
Plugins: Validation Reflection and Client-Side Validation
I''ve just put two plugins on RubyForge. Included below are the READMEs.
You can get the plugins at
svn://rubyforge.org//var/svn/valirefl/validation_reflection/trunk
svn://rubyforge.org//var/svn/clientsidevali/client_side_validation/trunk
Michael
Validation Reflection
=====================
Version 0.2, 2006-08-06
This plugin adds reflective access to validations
-