Class: IshLibManager::NewsitemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_lib_manager/newsitems_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_lists

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/ish_lib_manager/newsitems_controller.rb', line 12

def create
  authorize! :create, ManagerNewsitem.new

  n = Newsitem.new params[:newsitem]
  n.report = Report.find params[:newsitem][:report_id] unless params[:newsitem][:report_id].blank?
  n.gallery = Gallery.find params[:newsitem][:gallery_id] unless params[:newsitem][:gallery_id].blank?
  n.photo = Photo.find params[:newsitem][:photo_id] unless params[:newsitem][:photo_id].blank?
  n.descr = params[:newsitem][:descr]

  @city = City.find params[:city_id]
  @city.newsitems << n

  if @city.save
    flash[:notice] = 'Success'
    redirect_to edit_manager_city_path( @city.id )
  else
    flash[:error] = 'No Luck. ' + @city.errors.inspect
    render :action => :new_newsitem

  end
end

#destroyObject



40
41
42
43
44
45
46
# File 'app/controllers/ish_lib_manager/newsitems_controller.rb', line 40

def destroy
  @site = Site.find params[:site_id]
  @newsitem = @site.newsitems.find params[:id]
  authorize! :destroy, @newsitem
  @newsitem.remove
  redirect_to site_path( @site.id )
end

#indexObject



37
38
# File 'app/controllers/ish_lib_manager/newsitems_controller.rb', line 37

def index
end

#newObject



4
5
6
7
8
9
10
# File 'app/controllers/ish_lib_manager/newsitems_controller.rb', line 4

def new
  authorize! :new, ManagerNewsitem.new

  @newsitem = Newsitem.new
  @city = City.find params[:city_id]

end

#showObject



34
35
# File 'app/controllers/ish_lib_manager/newsitems_controller.rb', line 34

def show
end

#updateObject



48
49
# File 'app/controllers/ish_lib_manager/newsitems_controller.rb', line 48

def update
end