简体   繁体   English

活动的管理映像字段显示为脏

[英]active admin image field is shown dirty

I am using ActiveAdmin gem for admin console in ROR application. 我在ROR应用程序的管理控制台中使用ActiveAdmin gem。 In my ActiveAdmin model-FeaturedEvent i have declared form for creating Featured event. 在我的ActiveAdmin模型-FeaturedEvent中,我声明了用于创建Featured事件的表单。 FeaturedEvent model as a image field so i tried writing it. FeaturedEvent模型作为图像字段,因此我尝试编写它。 but it says NoMethodError in Admin::FeaturedEvents#new undefined method `new' for nil:NilClass. 但是它在nil:NilClass的Admin :: FeaturedEvents#new未定义方法“新”中显示NoMethodError。 Following is my ActiveAdmin Model: 以下是我的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

Error in browser on navigating to create featured event: 导航以创建特色事件时浏览器出错:

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

Ok i got it. 好,我知道了。 Paperclip needs a different name for attachment declaration in FeaturedEvent model [I have other model in which image was used ]. 在FeaturedEvent模型中,回形针需要一个不同的名称来表示附件声明[我还有使用了图像的其他模型]。 Thank you Vishal 谢谢维沙尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM