ActiveAdmin.register Document do
controller do
def create
create!
end
end
end
This was working fine in ActiveAdmin 0.6.6 however after upgrading to v1.1.0 it is unable to find the create template and ActionView::MissingTemplate
is thrown:
Missing template documents/create, active_admin/resource/create, active_admin/base/create, inherited_resources/base/create, application/create with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :haml]}. Searched in:
* "/Users/ent/Desktop/Apps/vent/app/views"
* "/Users/ent/.rvm/gems/ruby-2.5.5/gems/activeadmin-1.1.0/app/views"
* "/Users/ent/.rvm/gems/ruby-2.5.5/gems/kaminari-core-1.1.1/app/views"
* "/Users/ent/.rvm/gems/ruby-2.5.5/gems/devise_cas_authenticatable-1.10.4/app/views"
* "/Users/ent/.rvm/gems/ruby-2.5.5/gems/devise-4.6.2/app/views"
Is there anything that has changed since the upgrade that I am missing? I have tried the following versions of active admin: 1.0.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.4.0, 1.4.1, 1.4.2, 1.4.3 however they all have the same error. Downgrading back to 0.6.6 seems to resolve the issue.
I think it's because create
does not typically have it's own view.
To fix it, you can use this construct and instruct controller action what to do on success / failure of the create action. In this example, on success we will redirect to the resource detail, on failure we will render the new
view (as most likely the validation of the resource failed and user needs update and resubmit the form):
controller do
def create
super do |success, failure|
success.html { redirect_to your_resource_path(resource), notice: "#{resource.name} has been created." }
failure.html { render :new }
end
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.