Mysql::Error: Incorrect key file for table
Few days ago my current Ruby on Rails project was been moved to a staging server with similar configuration of the live web site. Suddenly yesterday in one of the administration modules I started getting the following error:
Mysql::Error: Incorrect key file for table ‘/tmp/#sql_61a9_0.MYI’;
try to repair it
After searching about it on Google I landed to a Mysql bug page. I tried several things to fix this issue like:
- Running repair command on tables
- Importing a working copy from live server
- Recreating the database with the working data
- Switching over to a different database
- Tested locally with the database having issue
But nothing worked, so today I wrote to Rimu hosting’s tech support explaining about the problem.
I received a response within half hour and I really do appreciate their promptness. This pointed me into the right direction that the issue was not with MySQL but due to the fact that there was no disk space available on server.
[root@xxxxxxx ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 4.3G 4.3G 512k 100% /
Tada the problem was gone after freeing up some space on the server
Ruby on Rails All rights reserved - DHH
![]()
Few weeks ago while talking with my RoR buddies we happened to have a small discussion about David Heinemeier Hansson clearly instructing everyone not to use logo of Ruby on Rails for any commercial purpose where he himself is not being involved or you may say not being benefited. While going through an article about the same I came across really interesting facts and aspects. Like Ruby on Rails identity was community funded. Undoubtedly DHH is responsible for the heights to which Ruby on Rails have reached today.
As a matter of fact on the Ruby on Rails official web site a copyrights message can also be found stating:
"Rails", "Ruby on Rails", and the Rails logo are trademarks of
David Heinemeier Hansson. All rights reserved.
Ruby on Rails I believe is one of the most successful open source projects ever and that is because of its policies especially for contribution. Rails source code is available under MIT license but the Rails identity is covered by trade mark rights. Basically a trade mark is used for a lot different purpose and it is really debatable if Rails identity should be covered under a trade mark policy or not. A trade mark is used in trade of goods to indicate and distinguish source.
Around the world already there is lot of confusion going on about trade mark for open source projects for example for overcoming Linux sub licensing and trade marking problem an entirely new concept of Linux mark was coined.
Rails is neither a product or a service its just an open source project, at least that is what everyone thinks of it, not sure about DHH. So how can one obtain trade mark or service mark for Rails. If to DHH believe, source of Rails is of himself as the usage rights remains with him and he is just sharing a few rights with others, then are all the Rails contributors crazy to be contributing in the Rails framework so that it can be distinguished as a DHH thing. Does DHH wants the world to work for him for free and yeah he doesn’t owe us a shit!!
Article by Peter Cooper on Rails trademark rights of DHH
Rails flash hash for same request
In my very first project with Ruby on Rails several months ago I almost freaked out finding a better way for displaying a flash message for the same request and rendering an action instead of redirecting it elsewhere.
For those who are not aware about the flash message concept of Rails framework. There are times when we wish to show message to the user after processing his request say for an example if the user had entered incorrect username or password then we tell him ‘The entered username or password is incorrect please try again‘. So we just need to assign our "cool" message to a key in flash hash like flash[:notice] = "my really cool message" and in our layout that we use for our application we keep a place to display the message stored in flash[:notice].
In Rails there are two things render and redirect, redirect does as it sounds, it redirects the current request to some another action and render uses the same request and executes a different action instead of the one it was intended for or the one intended in a case where there is no redirect or render.
The flash hash is volatile in nature and its default implementation is intended to be used with redirect. As soon as the next request is served the flash hash is flushed and so is the message stored in flash[:notice] is gone.
Now in a case where we use redirect like if we do the authentication in login action and lets application render the login action in the same request authentication took place. The message will be displayed if the authentication failed else we would redirect the user to his secret place having passed the authentication. But after a failed authentication request the message is not gone as a new request was not being served using redirect. Now if the user passes the authentication he will be taken to his secret place but the message is being retained in notice key of flash hash as it is being designed to, same will be the case if users navigates to some another part of application by clicking some link. Our "cool" message will be shown to the user in his secret place or any where he may go on his next request. Ouch that is what we were not willing to do.
So the solution for this is to assign our "cool" message to flash.now[:notice] instead of flash[:notice] well sounds quite obvious, isn’t Rails framework very human friendly. Using flash.now[:notice] will not retain the message for next request and flash[:notice] will have the message preserved for the current request it wont be available there after.
Rails Documentation of Flash Hash
active_scaffold_acts_as_list issue with template_search_path
These days I am making an application using Active Scaffold.
I needed to have reordering functionality in my application and found a plugin for the same called "active_scaffold_acts_as_list". Getting it to work was really a tricky part. I kept on getting errors while starting my server:
/vendor/plugins/active_scaffold_acts_as_list/init.rb:5:in
`load’: wrong number of arguments (1 for 0) (ArgumentError)
After trying to look for a solution to this I first tried changing load with require and now I was getting a new error:
/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb:
31:in `alias_method’: undefined method `template_search_path’
for class `Class’(NameError)
I was in doubt of this new problem being coming due to using require hence I tried looking for why load was not working and found that Rails::Plugin::Loader has already defined load method so a way to over come that was to use:
Kernel::load ‘config/core.rb’
I tried several things and thought that may be Active Scaffold was not getting loaded before active_scaffold_acts_as_list hence I tried to find out about the new feature I had heard recently in Rails on edge for specifying order or sequence for loading plguins.
I found a very useful article and even went through change logs on Rails trac after which I made changes to my environment.rb accordingly. But hard luck again it dint work
So I finally I went to Active Scaffold Google group and searched the discussion forum and found a thread that saved my life
It was more of a patch for fixing the exact problem I was facing and I followed what was suggested and viola now its working!!
Caching all the pages under a controller
I am working on a new Rails project these days and I was being asked to cache all the static pages displaying site’s static content. All the content was coming from one controller but I went crazy about implementing page caching by using caches_page, what I wanted to do was cache all the page in one go. Syntax for caching one or more pages is:
class WeblogController < ActionController::Basecaches_page :show, :newend
Now it is really a bad idea to go about writing all the content page names to ensure that they are cached. Even after looking for a solution to this on Internet I was unable to work out anything un-till I landed on a blog which was talking about a similar kind of problem. In responses to that post I finally found the solution:
after_filter lambda { |c| c.cache_page }, :except => [:show]
You are basically required to add a after filter to your controller of which you wish to cache all the pages, inside the except configuration you can specify the names of actions which you don’t want to be cached. So in short this works exactly the opposite of caches_page syntax.



