This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
2011-12-23 10:34:21 +00:00
|
|
|
class Admin::InfosController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :is_admin?
|
|
|
|
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
|
|
|
|
|
|
|
def index
|
|
|
|
@attributes = Info.all.entries
|
|
|
|
render :template => 'admin/attributes/index'
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@attribute = Info.new
|
|
|
|
render :template => 'admin/attributes/new'
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@attribute = Info.find(params[:id])
|
|
|
|
render :template => 'admin/attributes/edit'
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@attribute = Info.new(params[:info])
|
|
|
|
@attribute.save
|
|
|
|
redirect_to :action => :index
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@attribute = Info.find(params[:id])
|
2012-10-12 10:09:02 +00:00
|
|
|
# binding.pry
|
2011-12-23 10:34:21 +00:00
|
|
|
@attribute.update_attributes(params[:info])
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to :action => :index }
|
|
|
|
format.js { render 'admin/attributes/toggle_enable' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@attribute = Info.find(params[:id])
|
|
|
|
@attribute.destroy
|
|
|
|
redirect_to :action => :index
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_attribute_field
|
|
|
|
@attribute = Info.find(params[:id]) rescue nil
|
|
|
|
if !@attribute
|
|
|
|
@attribute = Info.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def set_attribute
|
|
|
|
@attribute_type = 'info'
|
|
|
|
@class = 'infos'
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|