i am using active admin to create a blog and i created sections which has_many :pages
, if i click on the section, it shows me the section mane cause i used `
<%= @section.name %>
, i want when i click on a section, it shows me all the pages in that sectionhere's my code show.html.erb
<h1><%= @section.name %></h1>
<% @catSections.each do |section| %>
<p><%= link_to section.name, section_path(section.id) %></p>
<% end %>
admin/section.rb
ActiveAdmin.register Section do
> permit_params :name
> index do
> column :id
> column :name, :sortable => :name
> actions end
>
> form do |f|
> f.inputs "Details" do
> f.input :name, :label => "Name"
> f.actions
> end
> end
>
> end
application_controller.rb
class ApplicationController < ActionController::Base
before_action :getAsideSection, :getCatSection, :getHeadCarousel
def hhome
end
def getAsideSection
@asideSections = Page.all
end
def getCatSection
@catSections = Section.all
end
def getHeadCarousel
@headCarousel = Carousel.all
end
end
admin/page.rb
ActiveAdmin.register Page do
permit_params :title, :body, :order, :is_published, :section_id, :menu_display
index do
column :id
column :title, :sortable => :title
column :section, :sortable => :section
column :created_at, :sortable => :created_at
column :order
actions
end
form do |f|
f.inputs "Details" do
f.input :title, :label => "Title"
f.input :section, :label => "Section"
f.input :body, as: :html_editor, :label => "Body"
f.input :order, :label => "Order"
f.input :is_published, :label => "Published"
f.input :menu_display, :label => "Display in Menu"
f.actions
end
end
end
Aucun commentaire:
Enregistrer un commentaire