Sha256: eed2c74453e1064b48913d27a5a89a77d470671f5b75b5fb65ca39d35a821f3e
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
class Lolita::RestController < ApplicationController include Lolita::Controllers::UserHelpers include Lolita::Controllers::InternalHelpers before_filter :authenticate_lolita_user! layout "lolita/layouts/application" def new build_resource show_form end def create build_resource save_and_redirect end def edit get_resource show_form end def update get_resource if self.resource self.resource=resource_with_attributes(self.resource,resource_attributes) save_and_redirect end end def destroy get_resource if self.resource && self.resource.destroy to_list end end def index page=resource_class.lolita.list.paginate(params[:page]) respond_to do |format| format.html do build_response_for(:list,:page=>page) end format.json do render :json=>page end end end private def show_form build_response_for(:tabs) if request.xhr? render :form, :layout => false else render :form end end def save_and_redirect if self.resource.save flash.now[:notice] = I18n.t "lolita.shared.save_notice" show_form else flash.now[:alert] = I18n.t "lolita.shared.save_alert" show_form #to_list end end def to_list page=resource_class.lolita.list.paginate(params[:page]) builder=build_response_for(:list,:page=>page) render :index #render_component *builder end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lolita-3.0.7 | app/controllers/lolita/rest_controller.rb |
lolita-3.0.6 | app/controllers/lolita/rest_controller.rb |
lolita-3.0.5 | app/controllers/lolita/rest_controller.rb |