Displaying 20 results from an estimated 10000 matches similar to: "[RoR],[C.L.R] How I convert a string object into a class?"
2008 Dec 02
2
Does a method string.to_class exist?
I have A Definition model, is it possible to do something like this in
Rails 2.1.0, Ruby 1.8.6 :
foo = "Definition"
@definition = foo.to_class.find(:all)
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group,
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 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
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 Sep 11
3
Extending ActiveRecord::Base
Hey everyone,
I''m interested in extending ActiveRecord::Base. I have a special
"easier" find function that I want to include in all classes.
How can I include this in all classes?
Can I just create a model object that does something like this:
class ExtendedAR < ActiveRecord::Base
def self.special_find
...
end
end
and then all my other classes
2009 May 19
4
proper way to ensure atomic model changes
Hi!
Say we have a rails active-record-based model called "instance" which
can have different states - STOPPED, RUNNING, STARTING_UP,
SHUTTING_DOWN, etc...
There is a method #start which changes the instance state to
STARTING_UP only if it is STOPPED.
def start
if self.state == STOPPED
self.state = STARTING_UP
self.save
...
end
end
As you understand if we have multiple
2005 Jul 26
6
implement audit trail table
has anyone has any idea how to implement audit trail table for all update /
deletion done on records?
I''m thinking to have corresponding audit trail table to each table, so
everthing before an update or deletion is done, a new record will be insert
into the corresponding audit trail table.
Is there a way to overwrite the save, destroy, method at the application
level? so that I do not
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
2010 Sep 15
5
OT: Installing static binary of wkhtmltopdf
This is OT but have not been able to get a response elsewhere (stack
overflow and the project site itself) so thought someone here might know or
have some ideas.
First, I am using wkhtmltopdf stand alone without any of the rails gems as I
found that for some reason using WickedPdf or PdfKit my pdf''s did not
generate with active links from the links from those in the html. When I run
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 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
2005 May 17
3
validates_associated / error_messages_for
When a validates_asssociated fails...
I get something like
Address is invalid
is there a way, preferably on a per-association basis to have the error
messaage include
the actual error like
Zipcode is too long (max is 10 characters)
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
2005 Aug 07
11
HABTM Movable Select Box
Hi,
I found it a while ago, an add-on to Rails for supporting movable select
boxes, but I searched through the wiki and the mailing list and couldnt
find what I was looking for. I was hoping someone might know of or
remember something about the project.
Thanks,
Dylan.
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
2005 Jun 13
3
validations not working with collection population droplists
I have an ADD form with foreign key field values selectable via select
list ( collection_select (...)).
When I add validates_presence_of :someotherfield to my model for error
trapping, I get the following error for each droplist:
NoMethodError in Reviews#create_curriculum
Showing /reviews/_form.rhtml where line #16 raised:
undefined method `inject'' for nil:NilClass
Extracted source
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
2010 Oct 06
16
Dealing with an EAV database
I''ve inherited an EAV database and there''s really no option to remodel
it. Data is stored as key_name, key_value pairs
Trying to return a meaningful, unified recordset is far too complex to
be efficient.
I''ve decided to make use of the MySQL GROUP_CONCAT, and CONCAT_WS
functions to return a fast query result, with the consolidated fields
as one string.
The final data is
2005 Sep 14
16
Showing database results in a grid view
Hello everyone,
It seems that the answer to my question should be obvious, but I''ve not
yet found a way to do what I want. Any advice on the best method would
be greatly appreciated.
Have the following database table:
CREATE TABLE datasets (
id int not null auto increment,
name varchar not null,
value varchar not null,
year varchar not null,
state
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 =>
2005 Dec 30
4
High performance queries - RoR, PHP or something else?
Hi everyone,
I''m building an app in RoR that apart from the normal web interface
has a web service. This web service takes a parameter and uses that in
a single database query, and returns the result in a simple XML
format.
This web service needs to be quite fast as it will be used on all
pages of a quite big site with thousands of visitors every hour. I
don''t think caching is