Register now and start sharing your code snippets.
-->

How to fix "Only get, head, post, put, and delete requests are allowed."

Ruby posted 2 months ago by christian

I’m getting this once in a while in development mode after changing the routes configuration:

   1  ActionController::MethodNotAllowed
   2  
   3  Only get, head, post, put, and delete requests are allowed.

The solution for me has been to restart the server.

Tagged bug, rails, problem, fix

Fix for "mysql error 1005 (errno: 150) "

SQL posted 4 months ago by christian

There are at least three reasons, that I know of, to why you could be seeing mysql error 1005

  • Adding a foreign key constraint when column types don’t match
  • Not enough privileges to execute the script
  • Trying to delete an index that is needed by some other index or constraint (“error on rename of”)

Use “SHOW ENGINE INNODB STATUS ;” to view the error:

   1  ALTER TABLE videos ADD constraint fk_videos_channels_id FOREIGN KEY (channel_id) REFERENCES channels (id);
   2  SHOW ENGINE INNODB STATUS;

Tagged mysql, sql, fix, problem, 150

Hpricot's inner_text doesn't handle HTML entities correctly

Ruby posted 7 months ago by christian

Hpricot’s inner_text method is fubar and doesn’t handle HTML entities correctly, instead you’ll see questionmarks in the output. To fix this replace calls to Hpricot’s inner_text with a call to the following method (or Monkey patch Hpricot):

   1  require 'rubygems'
   2  require 'htmlentities'
   3  
   4    def inner_text(node)
   5       text = node.innerHTML.gsub(%r{<.*?>}, "").strip
   6       HTMLEntities.new.decode(text)
   7    end

Remember to install the htmlentities gem:

   1  sudo gem install htmlentities

Tagged hpricot, inner_text, problem, bug