0

active_attr 및 simple_form을 사용하고 있습니다. 내 폼을 표시해야 페이지로 이동하면simple_form 및 active_attr 오류

나는 다음과 같은 오류가 발생합니다 :

class Message 

    include ActiveAttr::Model 

    attribute :name 
    attribute :email 
    attribute :subject 
    attribute :body 

    validates :name, :email, :subject, :body, :presence => true 
    validates :email, :format => { :with => %r{[email protected]+\..+} }, :allow_blank => true 

end 

내 컨트롤러 :

class ContactController < ApplicationController 
    def new 
    @message = Message.new 
    end 

    def create 
    @message = Message.new(params[:message]) 

    if @message.valid? 
     NotificationsMailer.new_message(@message).deliver 
     redirect_to(root_path, :notice => "Message was successfully sent.") 
    else 
     flash.now.alert = "Please fill all fields." 
     render :new 
    end 
    end 
end 

여기

undefined method `new_record?' for #<Message body: nil, email: nil, name: nil, subject: nil> 

내 모델입니다 그리고 마지막으로 내 견해 :

<%= simple_form_for @message, :url => contact_path do |f| %> 
    <%= f.input :name %> 
    <%= f.input :email %> 
    <%= f.input :subject %> 
    <%= f.input :body %> 
    <%= f.button :wrapped, :submit %> 
<% end %> 

답변

0

이 오류는 v0.7.0에서 수정 된 active_attr의 버그 때문이었습니다. 업그레이드하면 문제가 해결됩니다.

관련 문제