Sha256: fd3b6672c56cb360a0bacc94b492ed4cc833067af89ffb5a746adcd6134b090d
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
module Poodle module AdminFunctionalitiesHelper def get_collections(collection_name, **options) options.reverse_merge!( kls: collection_name.to_s.camelize.singularize.camelize.constantize ) relation = options[:kls].where("") @filters = {} if params[:query] @query = params[:query].strip relation = relation.search(@query) if !@query.blank? end objects = relation.order("created_at desc").page(@current_page).per(@per_page) instance_variable_set("@#{collection_name}", objects) unless instance_variable_get("@#{collection_name.to_s.singularize}") instance_variable_set("@#{collection_name.to_s.singularize}", objects.first) end return true end def render_list(collection_name, **options) respond_to do |format| format.html { get_collections(collection_name, **options) and render :index } format.js {} end end def render_or_redirect(error, redirect_url, action) respond_to do |format| format.html { if error render action: action else redirect_to redirect_url, notice: @message end } format.js {} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
poodle-rb-0.0.7 | app/helpers/poodle/admin_functionalities_helper.rb |