- ARCHIVE / Rails
- Grape will ignore a few things now
Another update to Grape: it will now ignore the doc, log, tmp and vendor/rails directories in its searches. No point crawling through the huge files that can build up in log or tmp, and doc is mostly auto-generated anyway. I have a habit of keeping large photoshop files and database backups in the doc folder [...]
- Intercepting JavaScript methods, Ruby-style
Ruby’s open classes and modules, along with alias_method, make it really easy to add functionality to existing methods. Take this example from my plugin AttrLocked:
class ActionView::Helpers::InstanceTag
def tag_with_attribute_locking(name, options = nil)
options = (options || {}).update(”disabled” => attribute_locked?)
tag_without_attribute_locking(name, options)
end
alias_method(:tag_without_attribute_locking, :tag)
alias_method(:tag, :tag_with_attribute_locking)
end
All [...] - Update for Grape: ‘view source’ mode
My little Rails project source code search plugin, Grape, now includes the ability to display search results in context with their surrounding source code, rather than just listing matching file paths. Par example:
>rake grape q=InitializerFound 3 files matching your search.
- /config/boot.rb : 14, 16, 30, 40, 44
[...] - Finding files with tiny fruit
I had to rename a bunch of variables in my current project and I wanted to know which files needed adjusting. Problem is, I’m on Windows, and searching for anything in Windows blows really hard. Even Google Desktop with the any-text-file-indexer wasn’t as helpful as I’d like. So, I wrote this tiny tiny plugin that [...]
- Stop repeating your labels
I don’t know about you, but I do like a bit of form_for. I’m not so fond of having to repeat myself when writing labels though:
<% form_for(:post, …) do |f| %>
<label for="post_title">Title</label>
<%= f.text_field(:title) %>
<label for="post_body">Body</label>
<%= f.text_area(:body) %>
[...] - Table locking in AttrLocked
As promised, AttrLocked has been updated to include table locking. If you have any tables in your app that you want to be read-only, just put this in your model:
class SomeReadOnlyTable < ActiveRecord::Base
table_locked
end
That will stop and save/update/delete operations on the model’s table, and you won’t be able to modify the attributes of any [...] - AttrLocked updated
I’ve just made an update to AttrLocked. The initial release allowed you to carry on setting locked attributes using the record[:attr] = value style. Now, both that and record.attr = value are disabled on locked attributes. I may add a feature that lets you lock down a whole table so it’s read-only, and you cannot [...]
- New Rails plugin: AttrLocked
I just released a new plugin for Rails, called AttrLocked. It lets you specify that certain model attributes should not be changeable once a record has been created - perfect for making sure usernames are fixed or your financial data doesn’t get tampered with. It will not let you change a record’s locked attributes in [...]
- Flagger 0.9.5 is out
Flagger got a little bug fix yesterday, in that it now recognises after_mark_as_* callbacks if they are private methods. This should really have been there in the beginning, I just left a couple of true arguments out somewhere. Get it like this:
script plugin intstall
http://svn.jcoglan.com/flagger/tags/0.9.5/flagger - Make Capistrano compress your JavaScript and CSS automatically
I finally gave Capistrano a whirl this morning by setting up a dummy application and getting a deployment to work. I must say, once it’s up and running it makes updating your application about as easy as it conceivably could be, and must save you loads of time if you have your app installed on [...]