Class: Admin::ComicController
- Inherits:
-
AdminCartoonistController
- Object
- AdminCartoonistController
- Admin::ComicController
- Defined in:
- app/controllers/admin/comic_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #lock ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #preview_random ⇒ Object
- #unlock ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/admin/comic_controller.rb', line 48 def create unless params[:image] flash[:message] = "Error: You must include an image when creating a new comic." return redirect_to "/admin/comic/new" end comic = Comic.create_comic params redirect_to "/admin/comic/#{comic.number}/edit" end |
#edit ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/admin/comic_controller.rb', line 58 def edit @comic = Comic.from_number params[:id] @edit_last_number = @comic.number - 1 @edit_next_number = @comic.number + 1 rescue ActiveRecord::RecordNotFound redirect_to "/admin/comic/new" end |
#index ⇒ Object
5 6 7 8 |
# File 'app/controllers/admin/comic_controller.rb', line 5 def index @unposted = Comic.unposted.numerical @posted = Comic.posted.reverse_numerical end |
#lock ⇒ Object
66 67 68 69 70 |
# File 'app/controllers/admin/comic_controller.rb', line 66 def lock comic = Comic.from_number params[:id].to_i comic.lock! redirect_to "/admin/comic/#{comic.number}/edit" end |
#new ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/admin/comic_controller.rb', line 41 def new last = Comic.current_created @next_number = Comic.next_number last @next_post_date = Comic.next_post_date last @edit_last_number = last.number if last end |
#preview ⇒ Object
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 |
# File 'app/controllers/admin/comic_controller.rb', line 10 def preview respond_to do |format| format.html do if params[:id].present? begin return redirect_to "/admin/comic/1/preview" if params[:id].to_i < 1 @comic = Comic.from_number params[:id] @disabled_next = @comic.maybe_newest? rescue return redirect_to "/admin/comic/preview" end else @comic = Comic.preview_current @disabled_next = true end @disabled_prev = true if @comic.oldest? render "comic/show", :layout => "comic" end format.png do comic = Comic.from_number params[:id] send_data comic.database_file.content, :filename => "comic_#{comic.number}.png", :type => "image/png", :disposition => "inline" end end end |
#preview_random ⇒ Object
37 38 39 |
# File 'app/controllers/admin/comic_controller.rb', line 37 def preview_random redirect_to "/admin/comic/#{rand(max_preview_comic) + 1}/preview" end |
#unlock ⇒ Object
72 73 74 75 76 |
# File 'app/controllers/admin/comic_controller.rb', line 72 def unlock comic = Comic.from_number params[:id].to_i comic.unlock! redirect_to "/admin/comic/#{comic.number}/edit" end |
#update ⇒ Object
78 79 80 81 |
# File 'app/controllers/admin/comic_controller.rb', line 78 def update comic = Comic.update_comic params redirect_to "/admin/comic/#{comic.number}/edit" end |