Sha256: 9b50fe30cd3cef35d187bae07910737a17284bb333e38e612a378ee34a4e26cc
Contents?: true
Size: 1.67 KB
Versions: 6
Compression:
Stored size: 1.67 KB
Contents
module Adminpanel module RestActionsHelper def index index! do |format| format.html { render "shared/index" } end end def show show! do |format| format.html { render "shared/show" } end end def new set_collections new! do |format| format.html { render "shared/new" } end end def create create! do |success, failure| success.html do flash.now[:success] = I18n.t("action.save_success") render "shared/index" end failure.html do set_collections render "shared/new" end end end def edit edit! do |format| format.html do set_collections render "shared/edit" end end end def update update! do |success, failure| success.html do flash.now[:success] = I18n.t("action.save_success") render "shared/index" end failure.html do set_collections render "shared/edit" end end end def destroy destroy! do |format| format.html { render "shared/index" } end end private def set_collections @collections = {} @model.belongs_to_relationships.each do |class_variable| @collections.merge!({"#{class_variable}" => class_variable.find(:all)}) end @model.has_many_relationships.each do |class_variable| @collections.merge!({"#{class_variable}" => class_variable.find(:all)}) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems