2012-02-21 6 views
2

컨트롤러의 표시 및 편집 작업이 호출 될 때마다이 오류가 발생했습니다. 3.0.10에서 App 3.1으로 업그레이드했는데 문제는 다른 컨트롤러가 예상대로 작동하므로 업그레이드와 관련이 있습니다. RuntimeError : 예기치 않게 데이터 잘림 Error Rails 3.1

RuntimeError: unexpectedly data truncated:SELECT `courses`.* FROM `courses` WHERE `courses`.`id` = ? LIMIT 1 

내 컨트롤러의 편집과 액션

def edit 
... 
@course = Course.find(params[:id]) 
@title = "#{@course.name}'s Details" 
... 
end 

def show 
... 
@title = "Course Detail" 
@course = Course.find(params[:id]) 
... 
end 

을 보여 MySQL의

을 사용하여 임 그리고보기는

<%= form_for @course do |f|%> 
     <%= render 'form' ,:f => f%> 
     <%= f.submit :class=> "btn " %> 
     <%= link_to "Delete User" , @course, :method =>:delete,:confirm =>"You Sure?", 
        :title => "Delete #{@course.email}",:class => "btn " %> 
     <%= link_to 'Cancel', courses_path,:class => "btn" %> 
<% end %> 

편집

오류의 원인에 관해서는 약간의 단서가

create_table "courses", :force => true do |t| 
t.string "date" 
t.string "time" 
t.string "venue" 
t.integer "roomnumber" 
t.string "tutor" 
t.string "type" 
t.string "name" 
t.string "description" 
t.string "status" 
t.string "duration" 
t.integer "maxallowed" 
t.datetime "created_at" 
t.datetime "updated_at" 
end 
+0

더 많은 정보가 필요하다고 생각합니다. 질문을 편집하고 schema.db에서 courses 테이블 섹션을 추가하여 정의 방법을 볼 수 있습니까? –

답변

0

이것은 열 중 하나에서 설정하려고하는 데이터가 255 자 (t.string의 기본값)보다 길기 때문에 Mysql 드라이버에서 발생합니다. before_save 데이터를 자르거나 t.text로 선언하여 열 유형을 텍스트로 변경해야합니다. blob 필드가 비쌀 수 있으므로 필드가 길어야 만이 작업을 수행하십시오.

+0

두 개의 긴 문자열을 입력으로 시도했지만 여전히 동일한 문제가있었습니다. – dev

관련 문제