Archive for the ‘Tools, Frameworks & Best Practices’ Category.
April 5, 2011, 12:11 am
In the helper file, ie tablenames_helper.rb, override the render_action_link method
def render_action_link(link, url_options, record = nil, html_options = {})
if link.parameters[:association] == :my_association
# special handling here
else
super # in case you have other associations for which you do want the default behavior
end
end
This confounded me for a while as it was easy to create a helper to override the link to associated records, but if the records did not yet exist the ‘Create New’ appeared hardcoded. After inspection of ./bundler/gems/active_scaffold-45451d963672/lib/active_scaffold/helpers/list_column_helpers.rb and ./bundler/gems/active_scaffold-45451d963672/lib/active_scaffold/helpers/view_helpers.rb the above override became apparent. Is there an easier way to determine this sort of thing?
April 1, 2011, 1:12 am
After a bit of refactoring of one of my controllers in a Rails3 app, the layout mysteriously disappeared, with
Rendered vendor/plugins/active_scaffold/frontends/default/views/list.html.erb (188.5ms)
replacing
Rendered vendor/plugins/active_scaffold/frontends/default/views/list.html.erb within layouts/application (192.1ms)
in the Rails debug output. Turned out to be a simple error – I added a routine to initialize some instance variables and forgot the ’super’ at the end to call the parent class initializer:
def initialize
... my instance vars ...
super
end
February 28, 2011, 8:54 am
Just had to write a script to do some processing on a tab-delimited file that contained some Hebrew UTF-8 chars, including a json chunk containing some Hebrew. Major headache with Perl – either got ‘wide char in subroutine’ errors, or escaped codes in the JSON. Needed to compare the UTF-8 tab-delimited fields with specific pieces of JSON, and have them both handled as UTF-8. Tried use utf8; binmode(STDIN, ':utf8') and various other permutations, but couldn’t get the output to look the way I wanted while keeping all the subroutines happy.
Implemented the same thing in Ruby, and it just worked. I’ve been a Perl girl for years, but am leaning Ruby…
February 1, 2011, 9:44 am
Check it out – Jeff Su, a developer on our team at Factual.com has had really good results using Varnish, written up here:
A Practical Guide to Varnish
For sites that need to ramp up suddenly, this could be a lifesaver…
January 7, 2011, 9:33 am
The instructions at http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ are slightly out of date or incorrect. Instead of setting
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.22/bin/java # do NOT do this
as you might expect from their instructions, you should
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.22/
October 28, 2010, 1:55 pm
Needed to build a recent version of RPM from source. When running ./configure for rpm-4.8.1, I ran into the ‘configure: error: missing required NSPR / NSS header’ error referenced at
http://lists.rpm.org/pipermail/rpm-list/2009-May/000253.html
The solution there is good but incomplete, a peek into the configure file reveals that they are really checking for ’sechash.h’ which is in the nss-devel package. After doing a
yum install nss-devel
as well as
yum install nspr-devel
then I can successfully run
./configure CPPFLAGS=”-I/usr/include/nspr4 -I/usr/include/nss3″
(well, almost successfully…now I am on to the next error message about a Berkeley Db directory not present…if that seems tricky as well will post a solution here, if straightforward I won’t bother…)
August 14, 2010, 12:19 pm
Just posted a patch: Expanded predicates for Relations API that gets one step closer to being able to combine free tagging with RDF. Basically the idea is simple: use the existing free tagging capabilities of Drupal to let users build up a smart domain-specific vocabulary, and use those words as predicates in RDF statements. I’m kind of surprised there didn’t seem to already be an easy way to do this.
The patch above does the step of including the vocabulary terms as predicates for Relations API. I still need to do another patch, probably to taxonomy_xml, to automatically expose them as RDF, and then expose something that makes it easy to output them in nice clean RDFa with the nodes. Once that is done, it seems pretty powerful to me. I like being able to write something and in a structured way say it was inspired by a book, that it implements a philosophy, or that it is useful for some specific goal.
This is partly done at bteaching.com now; the relations are visible to the user along with each node. They aren’t output in RDFa yet, though, that still needs to be done along with the automatic vocabulary exposure as RDF.
Anyway, I wanted to post what I have so far, as its in production on a live site and might be useful for someone else in its current form.
July 15, 2010, 5:48 pm
by Golda Velez
Just fifteen years ago, few organizations had websites. Those that did, owed thanks to some nerdy staffers or volunteers who had heard about the web, learned HTML, and hacked something together. Fast forward to today: most organizations, millions of people as well as several dogs, cats and birds have their own websites. Such proliferation has been assisted by numerous standards and tools that have emerged to aid with creating, editing and maintaining said sites. For most organizations, the key tool is a Content Management System (CMS); others design and build their own web application using a coding framework. Drupal is a bit of both, CMS and application coding framework.
Note, Drupal is by no means the only or necessarily the best choice for site building. Choices abound: Wordpress for simplicity and elegance, CodeIgniter or Symphony for efficient PHP application coding, newcomers such as CubicWeb built on emerging semantic standards – google ‘choosing a CMS’ if looking for advice on selecting a system for a new site.
Suppose, however, that you have inherited a Drupal site or have chosen Drupal on its merits as a mature, open source platform with a thriving community of users and developers and a plethora of modules to perform nearly every conceivable web task. Then it behooves you to understand the Drupal Way of avoiding pain and achieving maintainability.
Continue reading ‘The Drupal Way’ »
June 14, 2010, 5:49 pm
Drupal 6 generally is a solid version, notwithstanding the INSTALL.txt issue. It has good RDF support as well, including the ability to add and manipulate arbitrary triples using the RDF module. The Relations API module provides an easy user interface to add SeeAlso relations to nodes, but not to include nodes in arbitrary triples.
From the README.txt that comes with the Relations API: ” Currently supports bidirectional node relationships based on the rdfs:seeAlso predicate. This could in the future fairly easily be extended to include support for user-defined predicates and for unidirectional relationships.” – so this was part of the possible future plans, at least.
Since most of the RDF work appears now to be focusing on Drupal 7, I’m hoping that arbitrary relations make it in there. What I would really like to see is the use of the taxonomy terms vocabulary that the RDF module auto-generates used as the predicate set – that would essentially reach the “en:anyword” goal mentioned below, and in a widely used CMS! Perhaps this will be possible by extending the Relations API. For now, using it in standard form at a teaching tips site, http://bteaching.com
June 6, 2010, 5:09 pm
So, I am ping-ponging around in my spare-time quest for the best way to quickly add triples to the web on a nice user-friendly content-rich website.
Latest attempt involves Drupal 6 and the Relations API module, as it seems to me that Drupal 7 doesn’t yet have this particular functionality (though I am hoping it will by code freeze!)
Anyway, thus my latest discovery: the installation instructions in the INSTALL.txt packaged with Drupal 6.17 are WRONG. They tell you to make a copy of default.settings.php to settings.php before you visit the new site the first time and choose your language. This will result in annoying error messages like so: “Warning: Table ‘mydb.access’ doesn’t exist query: SELECT 1 FROM access WHERE type = ‘host’ AND …”.
Luckily the solution is documented here:
http://drupal.org/node/464982
but would it be too much to ask to correct the INSTALL.txt file for us old-fashioned text-doc-reading types?