I have code :
ActiveAdmin.register MyTable do controller do
def edit
#---This code doesn't work
render :template=>"myEditTemplate.html",:layout =>"active_admin"
end
def new
#--code in this section works fine
render :template=>"myNewTemplate.html",:layout =>"active_admin"
end
end
I want to see my edit template code under url like this: http://*/admin/mytable/1/edit BUT activeadmin doesn't see me my code/It shows code with own template not my Why?
You should be able to do this via the form
DSL method provided by ActiveAdmin. More details are in the documentation for ActiveAdmin and Formtastic.
Unfortunately, I don't believe ActiveAdmin nicely lets you have a completely different form rendered for new
and edit
. Using the partial rendering method in the documentation though you could conditionally change the form in the view based on @object.persisted?
.
# app/admin/post.rb
ActiveAdmin.register Post do
form :partial => "form"
end
# app/views/admin/post/_form.html.erb
<%= semantic_form_for [:admin, @post] do |f| %>
<% if @post.persisted? %>
Edit Form (Maybe rendered via a partial)
<%= f.inputs :title, :body %>
<%= f.buttons :commit %>
<% else %>
New Form
<% end %>
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With