diff --git a/app/controllers/admin/admin_controller.rb b/app/controllers/admin/admin_controller.rb index 80e1707..5a3ab5b 100644 --- a/app/controllers/admin/admin_controller.rb +++ b/app/controllers/admin/admin_controller.rb @@ -3,13 +3,13 @@ class Admin::AdminController < ApplicationController before_filter :authenticate_admin_user! before_filter :admin_menu - force_ssl :host => APP_CONFIG[:ssl_hostname] + force_ssl host: APP_CONFIG[:ssl_hostname] def admin_menu - @admin_menu = { :dashboard => '', - :admin_users => '', - :categories => '', - :photos => '', - :pages => '' } + @admin_menu = { dashboard: '', + admin_users: '', + categories: '', + photos: '', + pages: '' } end end diff --git a/app/controllers/admin/admin_users_controller.rb b/app/controllers/admin/admin_users_controller.rb index 839fb11..6e2f56e 100644 --- a/app/controllers/admin/admin_users_controller.rb +++ b/app/controllers/admin/admin_users_controller.rb @@ -15,14 +15,10 @@ class Admin::AdminUsersController < Admin::AdminController def update @admin_user = AdminUser.find(params[:id]) - respond_to do |format| - if @admin_user.update_attributes(permitted_params) - format.html { redirect_to(admin_admin_users_path, :notice => 'Admin User was successfully updated.') } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @admin_user.errors, :status => :unprocessable_entity } - end + if @admin_user.update_attributes(permitted_params) + redirect_to admin_admin_users_path, notice: 'Admin User was successfully updated.' + else + render :edit end end @@ -31,11 +27,9 @@ class Admin::AdminUsersController < Admin::AdminController respond_to do |format| if @admin_user.save - format.html { redirect_to(admin_admin_users_path, :notice => 'Admin User was successfully added.') } - format.xml { head :ok } + redirect_to admin_admin_users_path, notice: 'Admin User was successfully added.' else - format.html { render :action => "edit" } - format.xml { render :xml => @admin_user.errors, :status => :unprocessable_entity } + render :edit end end end @@ -44,10 +38,7 @@ class Admin::AdminUsersController < Admin::AdminController @admin_user = AdminUser.find(params[:id]) @admin_user.destroy - respond_to do |format| - format.html { redirect_to(admin_admin_users_path, :notice => 'Admin User was deleted.') } - format.xml { head :ok } - end + redirect_to admin_admin_users_path, notice: 'Admin User was deleted.' end # Allow the current logged in user to change their password @@ -59,8 +50,8 @@ class Admin::AdminUsersController < Admin::AdminController @admin_user = current_admin_user if @admin_user.update_with_password(permitted_params) - sign_in(@admin_user, :bypass => true) - redirect_to admin_dashboard_path, :notice => "Password updated!" + sign_in @admin_user, bypass: true + redirect_to admin_dashboard_path, notice: "Password updated!" else render :edit_password end diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 62ebbe3..54a6f3a 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -15,39 +15,28 @@ class Admin::CategoriesController < Admin::AdminController def update @category = Category.find(params[:id]) - respond_to do |format| - if @category.update_attributes(params[:category]) - format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully updated.') } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @category.errors, :status => :unprocessable_entity } - end + if @category.update_attributes(params[:category]) + redirect_to admin_categories_path, notice: 'Category was successfully updated.' + else + render :edit end end def create @category = Category.new(params[:category]) - respond_to do |format| if @category.save - format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully added.') } - format.xml { head :ok } + redirect_to admin_categories_path, notice: 'Category was successfully added.' else - format.html { render :action => "edit" } - format.xml { render :xml => @category.errors, :status => :unprocessable_entity } + render :edit end - end end def destroy @category = Category.find(params[:id]) @category.destroy - respond_to do |format| - format.html { redirect_to(admin_categories_path, :notice => 'Category was deleted.') } - format.xml { head :ok } - end + redirect_to admin_categories_path, notice: 'Category was deleted.' end end diff --git a/app/controllers/admin/confirmations_controller.rb b/app/controllers/admin/confirmations_controller.rb index 1561fa2..12d4761 100644 --- a/app/controllers/admin/confirmations_controller.rb +++ b/app/controllers/admin/confirmations_controller.rb @@ -2,7 +2,7 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController layout "admin/layouts/login" skip_before_filter(:authenticate_user!) - # PUT /resource/confirmation + def update with_unconfirmed_confirmable do if @confirmable.has_no_password? @@ -23,7 +23,6 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController end end - # GET /resource/confirmation?confirmation_token=abcdef def show with_unconfirmed_confirmable do if @confirmable.has_no_password? @@ -38,6 +37,7 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController end protected + def with_unconfirmed_confirmable @confirmable = AdminUser.find_or_initialize_with_error_by(:confirmation_token, params[:confirmation_token]) if !@confirmable.new_record? @@ -57,4 +57,4 @@ class Admin::ConfirmationsController < ::Devise::PasswordsController set_flash_message :notice, :confirmed sign_in_and_redirect(resource_name, @confirmable) end -end \ No newline at end of file +end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index df6c4bd..c0b4183 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -15,28 +15,20 @@ class Admin::PagesController < Admin::AdminController def update @page = Page.find(params[:id]) - respond_to do |format| - if @page.update_attributes(params[:page]) - format.html { redirect_to(admin_pages_path, :notice => 'Page was successfully updated.') } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @page.errors, :status => :unprocessable_entity } - end + if @page.update_attributes(params[:page]) + redirect_to admin_pages_path, notice: 'Page was successfully updated.' + else + render :edit end end def create @page = Page.new(params[:page]) - respond_to do |format| - if @page.save - format.html { redirect_to(admin_pages_path, :notice => 'Page was successfully added.') } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @page.errors, :status => :unprocessable_entity } - end + if @page.save + redirect_to admin_pages_path, notice: 'Page was successfully added.' + else + render :edit end end @@ -44,10 +36,7 @@ class Admin::PagesController < Admin::AdminController @page = Page.find(params[:id]) @page.destroy - respond_to do |format| - format.html { redirect_to(admin_pages_path, :notice => 'Page was deleted.') } - format.xml { head :ok } - end + redirect_to admin_pages_path, notice: 'Page was deleted.' end end diff --git a/app/controllers/admin/photos_controller.rb b/app/controllers/admin/photos_controller.rb index afad01c..252ad85 100644 --- a/app/controllers/admin/photos_controller.rb +++ b/app/controllers/admin/photos_controller.rb @@ -16,39 +16,28 @@ class Admin::PhotosController < Admin::AdminController def update @photo = Photo.find(params[:id]) - respond_to do |format| - if @photo.update_attributes(params[:photo]) - format.html { redirect_to(admin_photos_path, :notice => 'Photo was successfully updated.') } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } - end + if @photo.update_attributes(params[:photo]) + redirect_to admin_photos_path, notice: 'Photo was successfully updated.' + else + render :edit end end def create @photo = Photo.new(params[:photo]) - respond_to do |format| if @photo.save - format.html { redirect_to(admin_photos_path, :notice => 'Photo was successfully added.') } - format.xml { head :ok } + redirect_to admin_photos_path, notice: 'Photo was successfully added.' else - format.html { render :action => "edit" } - format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } + render :edit end - end end def destroy @photo = Photo.find(params[:id]) @photo.destroy - respond_to do |format| - format.html { redirect_to(admin_photos_path, :notice => 'Photo was deleted.') } - format.xml { head :ok } - end + redirect_to admin_photos_path, notice: 'Photo was deleted.' end private diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c084e08..f83aefc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery - rescue_from ActiveRecord::RecordNotFound, :with => :render_404 + rescue_from ActiveRecord::RecordNotFound, with: :render_404 def after_sign_in_path_for(resource_or_scope) admin_dashboard_path @@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base end def render_404 - render 'errors/not_found', :status => 404 + render 'errors/not_found', status: :not_found end end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index a9959a4..b0d81a8 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -2,7 +2,7 @@ class CategoriesController < ApplicationController # GET /categories # GET /categories.xml def index - @categories = Category.order('sort ASC').paginate :page => params[:page], :per_page => 4 + @categories = Category.order('sort ASC').paginate page: params[:page], per_page: 4 @photos = Photo.featured.limit(2).order('RANDOM()') @@ -10,7 +10,7 @@ class CategoriesController < ApplicationController respond_to do |format| format.html # index.html.erb - format.xml { render :xml => @categories } + format.xml { render xml: @categories } end end @@ -21,7 +21,7 @@ class CategoriesController < ApplicationController respond_to do |format| format.html # show.html.erb - format.xml { render :xml => @category } + format.xml { render xml: @category } end end diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index ba724c7..69ef4cb 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -1,13 +1,13 @@ class ContactsController < ApplicationController def new - @contact = Contact.new(:id => 1) + @contact = Contact.new(id: 1) @page_title = 'Contact' end def create @contact = Contact.new(params[:contact]) if @contact.save - redirect_to(:new_contact, :notice => t("contact.thanks")) + redirect_to(:new_contact, notice: t("contact.thanks")) else flash[:alert] = t("contact.invalid") render :new diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 3214fd8..5bde376 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -2,10 +2,10 @@ class PhotosController < ApplicationController def index if params[:category_id] @category = Category.find_by_id(params[:category_id]) - @photos = @category.photos.enabled.order{taken_at.desc}.paginate(:page => params[:page], :per_page => 11) + @photos = @category.photos.enabled.order{taken_at.desc}.paginate(page: params[:page], per_page: 11) @page_title = @category.name else - @photos = Photo.enabled.order{taken_at.desc}.paginate(:page => params[:page], :per_page => 11) + @photos = Photo.enabled.order{taken_at.desc}.paginate(page: params[:page], per_page: 11) @page_title = 'All Photos' end respond_to do |format|