Class: Buttafly::ContentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Buttafly::ContentsController
- Defined in:
- app/controllers/buttafly/contents_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #patch ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/buttafly/contents_controller.rb', line 18 def create @originable = Buttafly::Spreadsheet.new(originable_params) if @originable.save redirect_to contents_path, notice: "#{@originable.name} has been uploaded." else redirect_to :root, notice: "Could not upload content" end end |
#destroy ⇒ Object
40 41 |
# File 'app/controllers/buttafly/contents_controller.rb', line 40 def destroy end |
#edit ⇒ Object
15 16 |
# File 'app/controllers/buttafly/contents_controller.rb', line 15 def edit end |
#import ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/buttafly/contents_controller.rb', line 28 def import if @originable.import! redirect_to :back, notice: "#{@originable.name} successfully imported" else redirect_to :back, alert: "Could not import #{@originable.name}." end end |
#index ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/buttafly/contents_controller.rb', line 43 def index if params[:state] files = Buttafly.originable.where(aasm_state: params[:state]).order(created_at: :asc) else files = Buttafly.originable.all.order(created_at: :desc) end @originable = Buttafly.originable.new @contents = files.order(:created_at).page(params[:page]).per(5) @legends = Buttafly::Legend.all @mapping = Mapping.new @targetable_models = Buttafly::Legend.targetable_models end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/buttafly/contents_controller.rb', line 8 def new @originable = Buttafly::Spreadsheet.new end |
#patch ⇒ Object
37 38 |
# File 'app/controllers/buttafly/contents_controller.rb', line 37 def patch end |
#show ⇒ Object
12 13 |
# File 'app/controllers/buttafly/contents_controller.rb', line 12 def show end |