Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

August 25 2011

August 16 2011

February 08 2011

Rails 3 Translation Missing Error

In one of my projects I had to use I18n and I had a problem always seeing something like:
translation missing: ru.activerecord.errors.messages.record_invalid when there is no translation found.
I prefer to see default English translation if there is a translation missing error, why not ?
Especially in development mode.
So here is a small piece of code that you can put into config/initializers folder:

module I18n
  def self.custom_handler(exception, locale, key, options)
    case exception
    when I18n::MissingTranslationData
      I18n::Backend::Simple.new.translate(:en, key, options || {})
    else
      raise exception
    end
  end
end
I18n.exception_handler = :custom_handler
Continue reading

December 14 2010

Rails 3 dynamic view_path

There is an easy way to add view path dynamicly inside ActionController using prepend_view_path or append_view_path. But there is a problem because each request will start a filesystem traversal to do a pathset, we don't want to do that especially if there is a big project.

So here is an idea of how to handle that view_path insertion...

Continue reading

September 14 2010

How do you organize your rss feeds reading ?

Once i started searching and subscribing to feeds, my Google Reader was rapidly filled up with all that shit (kidding), i meant interesting news posts. In order to make Google Reader easier to use and to make sure that i'm reading feeds that are important to me i have to get it organized. It seems very easy with all these tools in Google Reader, but in reality i tried many times and still missing lots of interesting posts from the feeds, maybe i just don't have time to read all that super organized mess ))

Reading blogs helps us remain valuable in our space. Sometimes it's hard to find time but there are ways to make that time efficient and once you got an organized list of favorite news sites and blogs into your reader, you are done.

I organize my feeds by how important is not to miss the content from each particular feed. So first typically are blogs of friends and people that I like to follow, people which don't generate posts with the same speed as new york times, so reading this first part takes maybe 20 minutes a day. Second part of feeds contains feeds of blogs I like, but don’t need to read every day. When I find a new interesting blog to follow, I will typically put it here until i'll decide where it will go. Third part of feeds are items that i rarely read. Typically, i'll read these items only if there is nothing to read and i don't wanna go to search something in the web, so i read it even rarer than fourth part of my feeds which makes more sense because here goes the fun stuff. So in fourth part i have those feeds that i read after work at the end of the day when my brain is already broken and can not even think, and all that remains is laugh out loud.

Continue reading

August 31 2010

Play fullscreen
Alcatraz cells

August 08 2010

Грабля

У Николаса Кейджа грабля как у меня


Read and post comments | Send to a friend

July 29 2010

July 19 2010

Production data for testing

Just an option of generating fixtures .yml files for testing.

This can be done by adding this code to application's Rakefile:

namespace :test do
  desc "Generate fixtures"
  task :new_fixtures => :environment do
    ["User", "Post", "Article"].each do |m|
      File.open("test/fixtures/#{m.constantize.table_name}.yml", 'w') do |f|
        m.constantize.find(:all).each do |i|
          f.puts "item_#{i.id}:
"
          i.attributes.each_pair do |name, value|
            f.puts "  #{name}: #{eval("i.#{name}.acts_like?(:time)", binding) ? eval("i.#{name}.to_s(:db)", binding) : value}
"
          end
        end
      end
    end
  end
end

Then run:

rake test:new_fixtures RAILS_ENV=production
Continue reading

July 14 2010

July 13 2010

Older posts are this way If this message doesn't go away, click anywhere on the page to continue loading posts.
Could not load more posts
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Just a second, loading more posts...
You've reached the end.