Displaying 15 results from an estimated 15 matches for "singletonmethods".
2006 Jun 26
5
How can I dynamiclly generate models?
...class_name=>''::#{self}''
end"
self.class_eval class_def
has_many :comments, :class_name=>"#{self.name}::Comment",
:order=>''created_at desc'', :dependent => :delete_all
extend Commentable::SingletonMethods
include Commentable::InstanceMethods
end
end
module SingletonMethods
end
module InstanceMethods
end
end
init.rb
require ''acts_as_commentable''
ActiveRecord::Base.send(:include, Commentable)
image.rb
acts_as_commentable
This results in I...
2006 May 06
3
Extending Rails plugins?
...ems that were
tagged with all four inclusively).
Is there a proper way to extend a Rails plugin so that problems are
minimized downstream when the plugin is upgraded? Or should I just dive
right in the plugin code and hack away?
FYR, I want to add a method to the following module:
==
module SingletonMethods
def find_tagged_with(list)
find_by_sql([
"SELECT #{table_name}.* FROM #{table_name}, tags, taggings " +
"WHERE #{table_name}.#{primary_key} = taggings.taggable_id " +
"AND taggings.taggable_type = ? " +...
2006 May 26
1
access a ActionControllers protected method from plugin?
...''rhtml'')
logger.error(match)
end
str
end
end
module TextConversion
module Acts
module Blog
def self.included(base)
base.extend(ClassMethods)
end
def acts_as_blog
class_eval do
extend TextConversion::Acts::Blog::SingletonMethods
end
end
end
module SingletonMethods
def convert_to_html(txt, text_filter, restrictions = [])
txt = Execute.execute_ruby_code(txt)
end
return txt
end
end
end
end
--
Posted via http://www.ruby-forum.com/.
2009 Sep 11
0
Need help with extending a plugin
...module TaggableExtras
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def acts_as_taggable_extras(options = {})
include ActiveRecord::Acts::TaggableExtras::InstanceMethods
extend ActiveRecord::Acts::TaggableExtras::SingletonMethods
end
end
module SingletonMethods
#nothing here yet
end
module InstanceMethods
#...some instance methods here, added to taggables
end
end
end
end
--
Posted via http://www.ruby-forum.com/.
2006 Sep 04
2
"include" versus "extend" - what's the difference
...ed(options = {})
# don''t allow multiple calls
return if
self.included_modules.include?(CollectiveIdea::Acts::Audited::InstanceMethods)
include CollectiveIdea::Acts::Audited::InstanceMethods
class_eval do
extend CollectiveIdea::Acts::Audited::SingletonMethods
cattr_accessor :non_audited_columns,
:audited_user_class_name, :audited_user_method
self.non_audited_columns = [self.primary_key,
inheritance_column, ''lock_version'', ''created_at'', ''updated_at'']
self.non_audited...
2005 Dec 29
3
Why do plugins use class_eval?
...base.extend(ClassMethods)
end
# declare the class level helper methods which
# will load the relevant instance methods
# defined below when invoked
module ClassMethods
def acts_as_fox
class_eval do
extend Foo::Acts::Fox::SingletonMethods
end
end
......
Why is the class_eval needed here in acts_as_fox? Here self is the module that
called acts_as_fox, which I''ve tested by adding a ''puts self.name'' in
acts_as_fox. Isn''t self.class_eval redundant? The code could look like...
2006 Feb 07
4
Ruby, Rails & Inheritance
Hi!
I am looking for a solution for the following problem:
Some of my models share some attributes and also was in need for some
extra features, so I created a class "RecordWithFeatures":
-----------------------------------------------------------------
class RecordWithFeatures < ActiveRecord::Base
# @Override
def self.descends_from_active_record?
superclass ==
2009 Dec 27
5
Difficulties in understanding Rail-Plugins in depth
...ixe
module Acts #:nodoc:
module Commentable #:nodoc:
module ClassMethods
def acts_as_commentable
has_many :comments, :as => :commentable, :dependent => :destroy
include Juixe::Acts::Commentable::InstanceMethods
extend Juixe::Acts::Commentable::SingletonMethods
end
end
Is this where the magic happens? I think so. This is really
ingeniously because you have to just write one line of code to extend
your other Class.
But now - on the core of the whole thing - there is my question: Why
does the Class which calls acts_as_commentable now that h...
2006 Mar 28
0
How to set session variable in plug-ins
...:Legacy::Rails::Test::InstanceMethods
end
before_filter do |controller|
set_aaa_uid("jdoe")
end
end
end
module InstanceMethods
def set_aaa_uid(uid)
session[:aaa_uid] = uid
end
end
module SingletonMethods
end
end
end
end
ActionController::Base.class_eval do
include ::Legacy::Rails::Test
end
--
Posted via http://www.ruby-forum.com/.
2006 Feb 28
0
acts_as_taggable vulnerable to attacks ?
Hi all !
I''d like to confirm if I''m reading correctly.
It seems ActiveRecord::Acts::Taggable::SingletonMethods#find_tagged_with
is vulnerable to SQL injection attacks:
def find_tagged_with(options = {})
options = { :separator => '' '' }.merge(options)
tag_names = ActiveRecord::Acts::Taggable.split_tag_names(options[:any]
|| options[:all], options[:separator])
raise "No tags w...
2006 Feb 16
1
[PATCH] acts_as_taggable plugin
...relli
Blog: http://spazidigitali.com
--
-------------- next part --------------
Index: lib/acts_as_taggable.rb
===================================================================
--- lib/acts_as_taggable.rb (revision 3214)
+++ lib/acts_as_taggable.rb (working copy)
@@ -25,12 +25,23 @@
module SingletonMethods
def find_tagged_with(list)
find_by_sql(
- "SELECT #{table_name}.* FROM #{table_name}, tags, taggings " +
+ "SELECT DISTINCT #{table_name}.* FROM #{table_name}, tags, taggings " +
"WHERE #{table_name}.#{primary_key} = ta...
2006 May 26
8
calling render_to_string outside of controller
How can I call render_to_string outside of a controller. I''m stuck on
this. I''ve nearly got my plugin finished but I can''t seem to get this
to work. The method is in ActionController::Base but it is protected.
--
Posted via http://www.ruby-forum.com/.
2006 Jun 30
0
find_by_sql not quoting properly (in acts_as_taggable plugin)
..."AND taggings.tag_id = tags.id AND tags.name
IN (?)", list]
)
end
Originally, this built a string directly to pass to find_by_sql, but
I changed it thusly:
trunk/vendor/plugins/acts_as_taggable/lib/acts_as_taggable.rb
r13 r127
25 25 module SingletonMethods
26 26 def find_tagged_with(list)
27 find_by_sql(
28 "SELECT #{table_name}.* FROM #{table_name}, tags,
taggings " +
29 "WHERE #{table_name}.#{primary_key} =
taggings.taggable_id " +
30 "AND taggings.taggable_type = '...
2005 Dec 02
43
ANN: acts_as_ferret
Hi all
This week I have worked with Rails and Ferret to test Ferrets (and Lucenes)
capabilities. I decided to make a mixin for ActiveRecord as it seemed the
simplest possible solution and I ended up making this into a plugin.
For more info on Ferret see:
http://ferret.davebalmain.com/trac/
The plugin is functional but could easily be refined. Anyway I want to share it
with you. Regard it as a
2005 Dec 02
43
ANN: acts_as_ferret
Hi all
This week I have worked with Rails and Ferret to test Ferrets (and Lucenes)
capabilities. I decided to make a mixin for ActiveRecord as it seemed the
simplest possible solution and I ended up making this into a plugin.
For more info on Ferret see:
http://ferret.davebalmain.com/trac/
The plugin is functional but could easily be refined. Anyway I want to share it
with you. Regard it as a