The lastest version of VoteFu has a few useful enhancements:
Protect against mass assignment forgery. The params hash will only be consulted for :vote => true or false. The rest has to be assigned in the controller.
The acts_as_voteable mixin now has support for tallying votes.
The documentation will be updated tonight, but briefly, here is what you can do with the new tally() method:
This will select the Items with between 1 and 10,000 votes, the votes having been cast within the last two weeks (not including today), then display the 10 last items in an alphabetical list.
Quotes. I love quoting people. I have a ton of quotes saved in text files, on my blog, in my various mood messages on IM platforms, and who-know-where-else.
I decided to build an application to manage, organize, and syndicate quotes. You can read more about it on my project page for MyQuotable.
If you read this blog, you are invited to participate in my open alpha of MyQuotable.com.
I made the classic coder mistake, and didn’t dig into the plugin code before working around it. I am leaving this post up instead of being embarrassed and deleting it because it a good example of why you should read your plugin code. After reading the code, I found that TAGLIST IS JUST AN ARRAY: you can simply do this and avoid all of the filter magic that I put in place below.
1
2
# in config/initializers/tag_list.rb
TagList.delimiter = " "
Drat. That’s way better.
As it turns out, this answer is in the README for acts_as_taggable_on_steroids, but not in acts_as_taggable_on. I’m sending Michael a note to ask him to include that detail in the documentation.
Original Post
Michael Bleigh’s acts_as_taggable_on plugin is a useful extension of acts_as_taggable_on_steroids.
When using it in forms, however, many users have noticed that the @model.tag_list field deals with comma separated lists of tags, like so:
1
2
# From the README@user.tag_list = "awesome, slick, hefty"# this should be familiar
If, in your edit view template, you provide a text field for your users to type in freeform tags, then you will find that your database tables have multiword tags instead of multiple tags. This is less than ideal. Users do not like to type commas.
Build your form like this, and you will see the issue when a user types in “awesome slick hefty” in the input box.
<% form_for([@model]) do f %>
<div id="model_tags">
Tags: <%= f.text_field :tag_list %>
</div>
...
<% end %>
My workaround involves using a before_filter to unroll the content of the input box, and a compactor method in the edit action to change the internal storage format of acts_as_taggable_on to the format that the user expects. Here is an example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# ... In the taggable_controller
before_filter :join_tag_list, :only=>[:create, :update]# GET /users/:id/quotes/1/editdef edit
@model||= Model.find(params[:id])
unroll_tag_list
end
private
def join_tag_list
# Split the tags on spaces and join into comma separated format
params[:model][:tag_list] = params[:model][:tag_list].split(" ").join(",")enddef unroll_tag_list
# Split the tags on commas and join into a single space separated string@model.tag_list = @model.tag_list.join(" ")end
That’s it! Now my users see and work with space-separated tags, and acts_as_taggable_on continues to store comma separated lists internally.
VoteFu is a voting mixin that allows you to extend your models to vote on one another. Largely based on Cosmin Radoi’s acts_as_voteable plugin, VoteFu adds named_scope support, a set of generators to make using the plugin easier, a :polymorphic association to the voting class (so you can have more than one model type perform votes), and some enhancements for Rails 2.1.
I have simplified the code it requires to cast a vote down from three to one. After setting up your models with the proper mixin functionality, you can cast votes like this:
1
2
3
4
5
voter.vote_for(voteable)# OR
voter.vote_against(voteable)# OR
voter.vote(voteable, [true|false])
You can also use the old acts_as_voteable sytnax (which will continue to be supported):
1
2
3
4
vote = Vote.new(:vote=>true)
m = Model.find(params[:id])
m.votes<< vote
user.votes<< vote
I hope you find the plugin useful. Comments and feedback welcome. If there is enough demand, I’ll open up a lighthouse project to track issues.
In technology, knowledge is the important asset. Sharing knowledge is the important work. Conversations are therefore the most critical element of the business.
There are particular conversations that are important to facilitate, encourage, and enable. As managers and architects of our businesses, it is important for us to make sure that productive, meaningful information flow is taking place within our organizations.
In an article that I cannot find an online reference to, John Fini suggests that innovators be removed from operation of the business. In Howard Anderson’s TR article detailing the organizational barriers to success, he suggests that the most creative set of people in the organization should have the least red tape to cut.
In my opinion, the only way to make this work in a large organization is to go Agile. If you’re in a position to choose, I think this is evidence that you should choose a startup over corporate IT if you care about inventing.
I made myself this promise my first day as Director of Software Engineering for a technology startup. Many people spend a lot of time trying to figure out the political landscape, the business environment, and the legacy on their first day of a new job.
It’s a better idea to rely on your own brain. That’s why you got hired.
It’s worth speaking your mind early, frequently, and candidly.
Forget about reputation and fallout. It’s much better to tell the truth as you see it, analyze it, and use it to bridge any divides between viewpoints. Sometimes, people that seem to really know what they are talking about…are bluffing. The only way to tell is to dig into what you don’t understand.
Call Bullshit. All the time. My boss has come to expect that of me. It’s part of my personal brand.
I’ve had it. I am moving from Typo to Wordpress. Why?
Typo is still buggy. I want to spend my blog time blogging, not reading logs/production.log to figure out WTF happened to my site.
After submitting many patches to Typo 5.0.3 and receiving not even a “Hey, got the patch, thanks…” I have deduced that Typo is not well maintained by anyone.
All the hosted blog solutions that I want (disqus, etc) have out-of-box integration with WordPress.
I still host at RailsPlayground. But now I don’t run my blog on Rails.
I went to B-School when I was stuck in a corporate job, looking for a way to climb to the next level of misery. By my last year of MBA classes, I had made a radical 180 in my thinking. Smart people don’t need to stick with lousy jobs. That is follower behavior. Lead and make a great job for yourself and others.
Innovation is not efficient. It is inherently wasteful. There is churn and rework. However, it is the only strategy to sustain a competitive advantage. So to the extent that you can organize your teams and processes to embrace this fact, you will be successful.
Self-organization and empowerment of teams has a really powerful influence on success. I had a garden one year that I micromanaged. I pruned it, weeded it, watered it, fertilized it, and generally over-managed. It died. The next year, I did a whole lot less micromanaging, and it grew to produce a lot of fruits. People are similar.