mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
Rescue from AccessError with pretty and informative error page
Add pagination to teams page
This commit is contained in:
parent
30230bf645
commit
fd0e681aa2
8 changed files with 24 additions and 20 deletions
|
@ -12,7 +12,6 @@ header .banner {
|
|||
position: relative;
|
||||
|
||||
img {
|
||||
width: em(430);
|
||||
height: em(200);
|
||||
position: absolute;
|
||||
top: em(20);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
|
||||
#teams {
|
||||
@include span-columns(12);
|
||||
|
||||
table {
|
||||
table-layout: auto;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
include Exceptions
|
||||
|
||||
helper :all
|
||||
helper_method :cuser, :strip, :return_here
|
||||
|
||||
|
@ -8,10 +10,6 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery
|
||||
respond_to :html, :js
|
||||
|
||||
include Exceptions
|
||||
|
||||
# Global methods
|
||||
|
||||
def cuser
|
||||
@cuser ||= User.find(session[:user]) if session[:user]
|
||||
end
|
||||
|
@ -37,20 +35,19 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def redirect_to_home
|
||||
redirect_to :controller => "articles", :action => "news_index"
|
||||
redirect_to controller: "articles", action: "news_index"
|
||||
end
|
||||
|
||||
def rescue_action(exception)
|
||||
case exception
|
||||
when AccessError
|
||||
render :text => t(:access_denied), :layout => true
|
||||
when Error
|
||||
render :text => exception.message, :layout => true
|
||||
when ActiveRecord::StaleObjectError
|
||||
render :text => t(:application_stale)
|
||||
else
|
||||
super exception
|
||||
end
|
||||
rescue_from AccessError do |exception|
|
||||
render 'errors/403', status: 403, layout: 'errors'
|
||||
end
|
||||
|
||||
rescue_from Error do |exception|
|
||||
render text: exception.message, layout: true
|
||||
end
|
||||
|
||||
rescue_from ActiveRecord::StaleObjectError do |exception|
|
||||
render text: t(:application_stale)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,7 +2,7 @@ class TeamsController < ApplicationController
|
|||
before_filter :get_team, only: [:show, :edit, :update, :destroy, :recover]
|
||||
|
||||
def index
|
||||
@teams = Team.search(params[:search]).paginate(per_page: 40, page: params[:page]).with_teamers_num(0).ordered
|
||||
@teams = Team.with_teamers_num(0).search(params[:search]).paginate(per_page: 80, page: params[:page]).ordered
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1>Current Contests</h1>
|
||||
<h1 class="title">Current Contests</h1>
|
||||
|
||||
<% @contests.each do |contest| %>
|
||||
<h3><%= link_to contest.name, contest %></h3>
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= will_paginate @teams %>
|
||||
|
||||
<div id="teams">
|
||||
<%= render partial: 'list', locals: { teams: @teams } %>
|
||||
</div>
|
||||
|
||||
<%= will_paginate @teams %>
|
|
@ -13,6 +13,8 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= will_paginate @users %>
|
||||
|
||||
<table id="users" class="striped">
|
||||
<tr>
|
||||
<th class="country"></th>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
set :branch, 'develop'
|
||||
set :branch, 'feature-redesign'
|
||||
set :deploy_to, '/var/www/virtual/ensl.org/staging/rails'
|
||||
|
||||
set :rails_env, 'staging'
|
||||
|
|
Loading…
Reference in a new issue