fixed issues editing buzz entries

This commit is contained in:
Jonathan Kolyer 2014-02-01 21:59:25 -06:00
parent d92d02a361
commit da9a001e43
2 changed files with 13 additions and 7 deletions

View File

@ -47,7 +47,7 @@ ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do
def create
promo = PromoBuzz.create_with_params(params[:jam_ruby_promo_buzz])
super
redirect_to('/admin/buzzs')
end
def edit
@ -59,7 +59,8 @@ ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do
end
def update
super
resource.update_with_params(params[:jam_ruby_promo_buzz]).save!
redirect_to('/admin/buzzs')
end
end

View File

@ -41,18 +41,23 @@ class JamRuby::Promotional < ActiveRecord::Base
end
class JamRuby::PromoBuzz < JamRuby::Promotional
attr_accessible :image, :text_short, :text_long
attr_accessible :image, :text_short, :text_long, :position, :aasm_state, :key
def self.create_with_params(params)
obj = self.new
obj.text_short = params[:text_short]
obj.text_long = params[:text_long]
obj.position = params[:position]
obj.aasm_state = params[:aasm_state]
obj.update_with_params(params)
obj.save!
obj
end
def update_with_params(params)
self.text_short = params[:text_short]
self.text_long = params[:text_long]
self.position = params[:position]
self.aasm_state = params[:aasm_state]
self
end
def admin_title
"Buzz #{created_at.strftime('%Y-%m-%d %H-%M')}"
end