Posted by pratik
on Monday, July 02
Sorry for the lame name. I was gonna name it link_to_sexy initially, but changed my mind at the last moment ;-)
This plugin is inspired from Josh Peek’s stringgable_shortcuts & Geoff Buesing’s patch
To install :
|
script/plugin install http://linktomagic.googlecode.com/svn/link_to_magic/ |
To use :
1.
This is short for doing <%= link_to h(@person.name), @person %>. Here, a littile bit of ActiveRecord::Base.to_s magic is involved too. Check out this pastie to understand what/how it does this.
2.
|
<%= link_to_something @person %> |
This is short for doing <%= link_to h(@person.something), @person %>.
Comments/suggestions welcome!
Posted by pratik
on Sunday, July 01
“Don’t use the plugin you cannot write yourself. “
They are to save your time. Oh well, of course everyone is allowed an exception or two.
And I hate it when plugins do something like :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
module Something::ActiveRecord
module Base
def self.included(base)
base.class_eval do
base.extend(ClassMethods)
end
end
module ClassMethods
def references_table_name(column_name, options)
stuff
end
end
end
end
ActiveRecord::Base.send(:include, Something::ActiveRecord::Base) |
Instead of :
1
2
3
4
5
6
|
module Something::ActiveRecord::Base
def references_table_name(column_name, options)
stuff
end
end
ActiveRecord::Base.send(:extend, Something::ActiveRecord::Base) |
Makes me not wanna use it.