Can Sphinx and foxy fixtures place nicely together? Due to the way Sphinx indexing works, foxy fixtures will often slow down the indexing process drastically. This article explains how to overcome this limitation.
Loading...
Can Sphinx and foxy fixtures place nicely together? Due to the way Sphinx indexing works, foxy fixtures will often slow down the indexing process drastically. This article explains how to overcome this limitation.
<% @categories.in_groups_of(2).each do |group| %><% group.each do |category| %> <% end %><%=h category.name %> <% end %>
What are you staring at? Move along, move along.
Many Rails plugins require that certain files like images, CSS, and JavaScript get copied to the public folder during installation. The typical way to do this is add code to install.rb, which then gets executed when you first install the plugin in your Rails project. What happens when the assets in a plugin you’re using change, though? You end up having to manually copy files around anytime the plugin gets updated, which is an extremely error-prone process.
I extracted asset_copier from an existing Terralien project. It fixes this problem beautifully. Once installed, it keeps the assets in your Rails project synchronized with your plugin. It even deletes assets from the Rails project that have been removed in the plugin.
To learn more, check out this post. If instant gratification is more your thing, install the gem directly and apply it to your target plugin:
sudo gem install pelargir-asset_copier --source=http://gems.github.com cd ~/some_rails_project script/generate asset_copier some_plugin
I’m in the middle of developing a Radiant extension for Terralien. Radius is the tagging language for Radiant, and today I figured out how to use a route from inside a custom tag class.
A typical Radius tag class might look like this:
module AwesomeTags
include Radiant::Taggable
tag "session:logout" do |tag|
"Logout"
end
end
You can see that the hard-coded URL isn’t exactly DRY. I’ve already defined a route for it. Why should I have to hard code it here? The solution:
module AwesomeTags
include Radiant::Taggable
include ActionController::UrlWriter
default_url_options[:host] = REGISTRY[:host]
tag "session:logout" do |tag|
"Logout"
end
end
Note that UrlWriter needs to know the host name to base its URLs off of. The host name gets set using the registry pattern. It will be different depending on whether the app is running in development or production mode.
The same method can be used to reference routes from inside ActiveRecord models.
“We have no government armed with power capable of contending with human passions unbridled by morality and religion. Avarice, ambition, revenge, or gallantry, would break the strongest cords of our Constitution as a whale goes through a net. Our Constitution was made only for a moral and religious people. It is wholly inadequate to the government of any other.” — John Adams
Matthew Bass is powered by WordPress | Using Tiga theme with a bit of Ozh + WP 2.2 / 2.3 Tiga Upgrade