Class: IshManager::NewsitemsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::NewsitemsController
- Defined in:
- app/controllers/ish_manager/newsitems_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
Alphabetized : ).
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
Alphabetized : )
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/ish_manager/newsitems_controller.rb', line 6 def create @newsitem = Newsitem.new params[:newsitem].permit! @resource ||= Ish::UserProfile.find params[:newsitem][:user_profile_id] if !params[:newsitem][:user_profile_id].blank? @resource ||= ::Gameui::Map.find params[:newsitem][:map_id] if !params[:newsitem][:map_id].blank? @resource.newsitems << @newsitem @resource.touch :create_newsitem, @resource if params[:photo] photo = Photo.create( :photo => params[:photo], :user_profile => @current_profile, descr: params[:descr], subhead: params[:subhead] ) @newsitem.photo = photo end url = case @resource.class.name when "Ish::UserProfile" user_profiles_path else root_path end flag = @newsitem.save && @resource.save if flag @resource.touch flash[:notice] = 'Success' redirect_to url else error = 'No Luck. ' + @newsitem.errors..to_s + " :: " + photo.errors..to_s flash[:alert] = error render :action => :new end end |
#destroy ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/ish_manager/newsitems_controller.rb', line 42 def destroy @newsitem = Newsitem.find params[:id] :destroy, @newsitem if @newsitem.destroy flash[:notice] = "Destroyed the newsitem." else flash[:alert] = "Cannot destroy the newsitem: #{@newsitem.errors.}." end redirect_to request.referrer ? request.referrer : '/' end |
#edit ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/ish_manager/newsitems_controller.rb', line 55 def edit @newsitem = Newsitem.find( params[:id] ) :edit, @newsitem ## @TODO: what on earth is this? out = Gallery.unscoped.where( :is_trash => false, :user_profile => @current_profile ).order_by( :created_at => :desc ) @galleries_list = [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] } end |
#index ⇒ Object
65 66 67 68 |
# File 'app/controllers/ish_manager/newsitems_controller.rb', line 65 def index :newsitems_index, @resource @newsitems = @resource.newsitems end |
#new ⇒ Object
70 71 72 73 |
# File 'app/controllers/ish_manager/newsitems_controller.rb', line 70 def new @newsitem = Newsitem.new :new, @newsitem end |
#update ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/ish_manager/newsitems_controller.rb', line 75 def update @newsitem = Newsitem.find params[:id] :update, @newsitem if params[:photo] photo = Photo.new :photo => params[:photo] photo.user_profile = @current_profile @newsitem.photo = photo end flag = @newsitem.update_attributes params[:newsitem].permit! if flag flash[:notice] = 'Success' else flash[:alert] = "No Luck: #{@newsitem.errors.}" end if (@newsitem.map) redirect_to map_path(@newsitem.map) else redirect_to edit_newsitem_path(@newsitem) end end |