Project

General

Profile

Actions

Feature #1506

closed

Add title length note and error info when creating project or creating news

Added by Chaoqun Zou over 16 years ago. Updated over 16 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
2008-06-20
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

I have encountered several times that there was none error info if the news title is too long, and the page would displayed a rails exception.

For example:

ActiveRecord::StatementInvalid in NewsController#new 
Mysql::Error: Data too long for column 'title' at row 1: INSERT INTO `news` (`created_on`, `project_id`, `title`, `description`, `summary`, `author_id`, `comments_count`) VALUES('2008-06-20 10:24:15', 3, 'the very long title that will cause exception', 'the news', 22, 0)
RAILS_ROOT: redmine
Application Trace | Framework Trace | Full Trace 
ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'
ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:in `execute'

And this will confuse the users who are not a developer.

So, I think it will be greate to add a length limit note on the creating page, and give out an error info rather than directly display the rails exception page.

Actions #1

Updated by Chaoqun Zou over 16 years ago

I have found that this is a gloc error, but still don't know how to resolve it.

When the news' title is in Chinese, gloc's validates_length_of method will use string.split(//).size to get the title length. Every Chinese character will be treated as 1 character. But when save to mysql, every Chinese character will be treated as 3 characters. So the gloc's validates_length_of will return success but actually the string length is much longer than the maxim length.

Actions #2

Updated by Chaoqun Zou over 16 years ago

Sorry about last post, that when I removed gloc's validates_length_of method and let active_record do the validates, I found that the activerecord's validates_length_of is the same as gloc's...

Actions #3

Updated by Chaoqun Zou over 16 years ago

  • Status changed from New to Resolved

I have finally found the reason that this is caused by my error database.yml.
Very sorry to post these invalid messages.

This error is caused by a error configured database.yml.
This is my error config:

development:
  adapter: mysql
  database: redmine_development
  host: localhost
  username: root
  password: mysql

And if use chinese in the system, we must add this encoding parameter:

  encoding: utf8

That is to say, when I correct my database.yml to:

development:
  adapter: mysql
  database: redmine_development
  host: localhost
  username: root
  password: mysql
  encoding: utf8

the problem is resolved!

Actions #4

Updated by Jean-Philippe Lang over 16 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Fixed

Thanks for the feedback. I've added this setting in database.yml.example.

Actions #5

Updated by Jean-Philippe Lang over 16 years ago

  • Target version set to 0.7.3
Actions

Also available in: Atom PDF