Displaying 20 results from an estimated 5000 matches similar to: "Is eval the only way?"
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|
2006 Apr 18
3
Join Queries? - find() or find_by_sql()
Hi All,
Is there a way to do join queries with find() or is it best to use
find_by_sql() instead?
I''m looking to do something like:
SELECT winery_name, wine_name FROM winery, wine
WHERE wine.winery_id = winery.winery_id
AND winery.winery_name LIKE ''Borg%'';
Thanks!
: )
Jason
2006 Jan 19
4
create an object from a string?
I''m trying to dynamically create an instance of an object at runtime, from a
String. I have a method that returns one of a number of Strings ("Car",
"Motorcycle", "Bicycle"), and when I receive the String, I then want to
instantiate one of those objects.
Seems like there should be a way to do it in Ruby, but maybe I''ve been up
too long --
2006 Feb 08
2
What page is an item on?
Using the paginator helper, is there a way to determine what page an
item in the collection is on?
Thanks in advance for your help!
2006 Apr 07
2
Re: Re: page.replace_html "#{var_containing_id_name}", :partial
> you mean like this?
>
> def do_some_ajax_thing
> <at> element_id = "content_div"
> end
>
> do_some_ajax_thing.rjs
>
> page.replace_html <at> element_id, :partial => "edit"
>
> remember, the view templates have access to the attributes defined
> in the controller
Actually, its more like this: I have a list page. Each row
2006 Aug 01
2
Active Merchant or Payment module?
Which do you guys prefer for credit card processing?
Both look like they get the job done. -- Is there any consensus on which
one is better? Are there other credit card processing solutions I''m not
aware of? Any thoughts or suggestions would be most welcome.
Thanks!
: )
Jason
--
Posted via http://www.ruby-forum.com/.
2006 Apr 07
2
Re: page.replace_html "#{var_containing_id_name}", :partial
Jeff Coleman <progressions@...> writes:
>
> Jason Tuttle wrote:
> > The subject line says it all. -- Is there a way to do something
like:
> >
> > page.replace_html "#{var_containing_id_name}", :partial => ''edit''
> >
> > That line of code does not work, but I would like to pass the
name of
> > a variable to
2006 Jan 20
1
stack level too deep from has_many / belongs_to relationship
I have the following 3 models (2 models joined by an intermediate):
1. class Exercise < ActiveRecord::Base
2. has_many :routines, :class_name=>''RoutineExercise''
3. end
1. class Routine < ActiveRecord::Base
2. has_many :exercises,
3. :class_name=>''RoutineExercise'',
4. :order=>''position''
5. end
1. class
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde
2006 Apr 07
2
page.replace_html "#{var_containing_id_name}", :partial => ''edit''
The subject line says it all. -- Is there a way to do something like:
page.replace_html "#{var_containing_id_name}", :partial => ''edit''
That line of code does not work, but I would like to pass the name of
a variable to page.replace_html. This variable would contain the id
of the div I want to update.
Anyone know if/how I could do that?
Thanks!
: )
Jason
2006 Oct 09
7
multi_search problems, Never go away!
Hello, I am trying to use the multi_search method, but I keep getting
type error on nil objects, I send it [Model1,Model2] and it seems as
though the class names keep getting clobbered and turn to nil, somewhere
along the multi_index area. I tried to trace what was going on, but I
got nothing, also, this only happens when there are actually hits(thank
god, most of the time). Perhaps some insight?
2007 Dec 13
8
stub with assigns?
is there a way to stub a method that sets an instance variable, so
the stub sets it too?
def find_foo
@foo = Foo.find(params[:id]
end
...
controller.stub!(:find_foo).and_assigns(:foo, "123")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071213/2042719f/attachment.html
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 =>
2012 Sep 22
4
Class, Module, Object
>> reload!
Reloading...
=> true
>> puts Class < Module
true
=> nil
>> puts Module < Class
false
=> nil
>> puts Module < Object
true
=> nil
>> puts Object < Module
false
=> nil
>> Object.parent
=> Object
The above indicates that the Class object instance inherits from the
Module object instance and the Module object instance
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really
be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again.
I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I
don''t just post it manually: I design a Rails-based inventory database that
creates a semantically-correct XHTML/CSS auction
2006 Apr 07
1
Re: page.replace_html "#{var_containing_id_name}",:partial
On 4/7/06, Chris Hall <christopher.k.hall@gmail.com> wrote:
> page.replace @user.id, :partial => "edit_form"
Thanks a lot Chris. -- Unfortunately, it didn''t quite work when I
tried it that way. However, when I tried it this way:
page.replace_html "#{@user.id}", :partial => "edit_form"
It worked!
Thanks again!!
: )
Jason
2006 Mar 26
4
edge and 1.8.2/1.8.4 issues
I recently upgraded to 1.8.4 to try out mongrel, and so far have been in
a kind of hell where I can''t get my app working!
Currently running (or trying to run):
Ruby version 1.8.4 (i386-mswin32)
RubyGems version 0.8.11
Rails version 1.0.0
Active Record version 1.13.2
Action Pack version 1.11.2
Action Web Service version 1.0.0
Action Mailer version 1.1.5
Active Support version
2006 Mar 06
4
Change to set_fixture_class
So, I sat down to use set_fixture_class, and it bombed on the first
thing I tried:
set_fixture_class :content_drafts => "Article::Draft"
I made a quick patch, and I''d appreciate a quick run through your
tests to make sure it doesn''t disturb anything:
http://dev.rubyonrails.org/ticket/4095
As I was typing this, I realized that the string gives us no benefits.
I
2007 Mar 21
2
store_class_name for Comatose:Page model
Hi,
I have three models: Comatose::Page, Article and Product.
In all of them, store_class_name is set to true.
Now, when i do:
results = Comatose::Page.multi_search("*", [Article,Product], options)
I get:
wrong constant name Comatose::Page
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:438:in
`const_get''
2008 Mar 12
12
Mongrel has crashed
Hi,
my mongrel has crashed with following errors in the logfile:
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no
restart).
** Rails signals registered. HUP => reload (without restart). It might
not work well.
** Mongrel 1.1.3 available at 0.0.0.0:3000
**