2011-08-05 202 views
0

下面的日志片段显示了传入的参数,但是当创建SQL插入语句时,它将插入所有值的空值而不是params中的值。你们可以给我一些想法来调试吗?我不知道从哪里开始未设置模型属性

Processing by CvitsController#create as HTML 
    Parameters: {"commit"=>"Submit", "authenticity_token"=>"uRicLgLLkzSSB62b/bqefI0tQ2lR6UX8axKWBtM0dsU=", "utf8"=>"✓", "cvit"=>{"cluster_dist"=>"10000", "textup"=>">Glyma02g37330 RING finger family [Glycine max]\r\nMNMHKESPLIKLHSFDQGHAWLALLHLLIHVSPAVTGQPVTPPVQPDSNKSMVTIMAILAIMFLILVFLSIYSRKCYDRQAPTRGILDRADPTG\r\nAAGNPSQAESNGLNQATIETFPSFLYGDVKGLKIGKDTLACAVCLNEFEDDETLRMIPKCCHVYHRYCIDEWLGSHSTCPVCRANLVPQPED\r\nVNINTNIPSILSIQIPDEHEHEYEYETVVVGEEHKRGNVVESPKVNLLRRIRSLNHQSRPSRSRSTGFLSSLLFSRSNSLGQMQLAHNAAGENYE\r\nRFTLRLPEEVRSQMMLQRANSCVCFTRMSSGTWGYRTTRSAGRRCVQYERFGGGDDEGWGFTLTPPSLIRNGWNNNRSTRKSQRSGLVLD\r\nNNNADEKSSEFLPLG*", "filter"=>"T", "min_identity"=>"60", "e_value"=>"1e-10", "program"=>"blastp", "species"=>"glycine_max"}} 
Creating scope :page. Overwriting existing method Cvit.page. 
    SQL (0.1ms) BEGIN 
    SQL (1.6ms) describe `cvits` 
    AREL (0.3ms) INSERT INTO `cvits` (`cluster_dist`, `fileup_file_size`, `textup`, `fileup_file_name`, `filter`, `created_at`, `program`, `fileup_updated_at`, `species`, `min_identity`, `updated_at`, `e_value`, `fileup_content_type`) VALUES (NULL, NULL, NULL, NULL, NULL, '2011-08-05 13:50:07', NULL, NULL, NULL, NULL, '2011-08-05 13:50:07', NULL, NULL) 
[paperclip] Saving attachments. 
    SQL (121.3ms) COMMIT 
Redirected to http://soybase.org:8085/cvits/4 
Completed 302 Found in 150ms 

型号:

class Cvit < ActiveRecord::Base 
    attr_accessor :species,:program,:textup,:e_value,:filter,:min_identity,:cluster_dist,:fileup_file_name 
    attr_accessor :base_path, :fa_file, :text_file, :dbase, :source, :bl_file, :bl_sorted, :gff_file, :cvt_file, :db, :overlay_coords_gray 

    def initilize(*args) 
    super(*args) 
    end 

    def cvitSetup() 
    . 
    . 
    . 
    end 
    def blast() 
    . 
    . 
    . 
    end 
    . 
    . 
    . 
end 
+2

一些示例代码可能是不错的。你的问题没有意义 – Yule

回答

2

变化attr_accessor到attr_accessible

+1

我不知道这是如何解决的。 attr_accessible关键字用于允许在某些字段上进行批量分配,但我不知道它在这里有帮助。通常,attr_accessible关键字就足够了。 – rookieRailer

+0

你在使用漂亮的脚手架吗? – rookieRailer

+0

我现在有其他问题见http://stackoverflow.com/questions/6959097/rails-attribute-set-correctly-in-console-but-not-in-view – bdeonovic