2011-11-13 1 views
0

내가 양식을 가지고 값,양식 매개 변수가 올바른지하지만 SQL은 다음과 같이 보이는이 (HAML 죄송 및 독일 부품)과 같은

= form_for @mentality, :url => { :controller => "mentalities", :action => "create" }, :html => { :class => "mentality_create", :method => :post } do |f| 
    = render 'shared/error_messages_einstellung', :object => f.object 
     .left 
     %h4 
      Welche Einstellung möchten Sie hinzufügen? 
     = f.text_field :title, :placeholder => "Name der Einstellung" 
     %br 
     = f.submit "Eintragen" 

그리고 모델 그리워 :

# encoding: utf-8 
class Mentality < ActiveRecord::Base 
    attr_accessible :title 

    belongs_to :user 

    validates :user_id,  :presence => true 
    validates :title,  :presence => true 

    default_scope :order => 'mentalities.created_at DESC' 

    self.per_page = 20 

end 

그래서 하나의 필드 만 쓸 수 있습니다. 제목은 title입니다. 내가 만드는 작업을 처리 할 경우, 로그는 말한다 :

INSERT INTO "mentalities" ("created_at", "title", "updated_at", "user_id") VALUES ('2011-11-13 11:26:48.078652', NULL, '2011-11-13 11:26:48.078652', 1) 

나는라는를 닮아 모델에 대한 컨트롤러와 전망이 :

Parameters: {"utf8"=>"✓", "authenticity_token"=>"ULjT8cxQ77KTh7+0rX6pzFpMaehBuUxGAA3AGh/Sbg8=", "mentality"=>{"title"=>"Test"}, "commit"=>"Eintragen"} 

그러나이 생성 SQL 문은, 제목이 없습니다 '카테고리'와 완벽하게 잘 작동합니다.

그래서 내 데이터베이스에 제목이 삽입되지 않은 이유를 설명 할 수 있습니까? 나는 그것이 왜 거기에 없는지 정말로 이해하지 못한다.

+0

조치 코드? –

+0

해결되었습니다. 방금 ​​MVC 전체를 제거하고 다시 추가했습니다. 왜 그것이 일어 났는지 모르지만 지금은 작동합니다. – Thomas

+0

가끔은 그게 중요합니다. :) –

답변

0

무슨 일인지 모르지만 방금 MVC 전체를 제거하고 다시 추가했습니다. 여전히 똑같아 보이지만 지금은 작동합니다.