2016-07-15 17 views
0

我在ROR應用程序中使用ActiveAdmin gem作爲管理控制檯。在我的ActiveAdmin模型-SelectedEvent中,我聲明瞭用於創建特色事件的表單。作爲圖像領域的FeaturedEvent模型,所以我試着寫它。但是在Admin :: FeaturedEvents#中新增了未定義方法`new'的nil:NilClass中的NoMethodError。以下是我的ActiveAdmin型號:活動管理圖像字段顯示爲髒

ActiveAdmin.register FeaturedEvent do 
permit_params do 
permitted = [:name, :location, :start_time, :description,:image,:phone, :email, :event_url, :active, :free, :image, :s3_credentials] 
permitted << :other if params[:action] == 'create' 
permitted 
end 

controller do 
def create 
    byebug 
    @featuredevent = Event.new(permitted_params[:featuredevent]) 

    if @featuredevent.save 
     redirect_to '/admin/featured_events#index' 
    else 
     flash[:message] = 'Error in creating image.' 
    end 


end 

def event_params 
    params.require(:event).permit(:name, :location, :start_time, :description,:image,:phone, :email, :event_url, :active, :free, :image, :s3_credentials) 
end 
end 

form do |f| 
inputs 'Create Private Events' do 

    input :image 
end 

actions do 
    button_to 'Create', featured_speakers_path(:featuredevent), method: :post 
      #link_to 'Create', {:controller => 'events', :action => 'create'}, {:method => :post } 
end 
end 

end 

錯誤在瀏覽器上導航到創建功能的事件:

**NoMethodError in Admin::FeaturedEvents#new** 
undefined method `dirty?' for nil:NilClass 
+0

你是用回形針嗎?? ?? – Vishal

+0

好吧,我明白了。回形針需要一個不同的名稱在FeaturedEvent模型中的附件聲明[我有其他使用圖像的模型]。謝謝Vishal –

回答

0

好吧,我明白了。回形針需要一個不同的名稱在FeaturedEvent模型中的附件聲明[我有其他使用圖像的模型]。謝謝Vishal

+0

wc bro :)我的榮幸:) – Vishal