Skip to content

Customizing model

Luiz Picolo edited this page Jun 9, 2016 · 2 revisions

rails_admin

content_builder do
  only ['ContentBuilder']
end

Remove

rails_admin_content_builder

New class

class ContentBuilder < RailsAdminContentBuilder::ContentBuilder

end

Routes content builder

path_url = 'admin/content_builder/:id/create_images'
path_method = 'rails_admin_content_builder/content_builder#create_images'
put path_url => path_method

Controller

class NewsController < ApplicationController
  before_action :set_news, only: [:show, :print]

  def index
    @news = ContentBuilder.list_all.page(params[:page])
  end

  def show
  end

  def list_by_category
    @news = ContentBuilder.list_by_category(params[:category]).page(params[:page])
  end

  def print
    render layout: false
  end

  private

  def set_news
    @news = ContentBuilder.find_by_slug(params[:slug])
    @news.content_builder_count_reads.create
  end
end
Clone this wiki locally