Skip to content

Instantly share code, notes, and snippets.

@Prevole
Created June 24, 2012 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Prevole/2982855 to your computer and use it in GitHub Desktop.
Save Prevole/2982855 to your computer and use it in GitHub Desktop.
Rendering problem
module Admin
class AdminController < ApplicationController
def initialize
@datatable_class = "#{self.class.to_s.gsub("Controller", "Datatable")}".constantize
@model_class = "Object::#{self.class.to_s.gsub("Admin::", "").gsub("Controller", "").singularize}".constantize
@param_path = "#{@model_class.to_s.gsub("::", "_").downcase}"
@model_name = "#{@model_class.to_s.demodulize.downcase}"
end
def index
respond_to do |format|
format.html
format.json {
@records = @model_class.all
render json: @datatable_class.new(view_context, @model_class)
}
end
end
end
end
class ApplicationController < ActionController::Base
protect_from_forgery
end
module Admin
module MyModule
class MyModelsController < Admin::AdminController
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment