lib/enju_leaf.rb in enju_leaf-1.1.0.rc12 vs lib/enju_leaf.rb in enju_leaf-1.1.0.rc13

- old
+ new

@@ -4,13 +4,12 @@ require "enju_leaf/user" require "enju_leaf/helper" require "enju_leaf/calculate_stat" require "enju_leaf/bookmark_url" require "enju_leaf/calculate_stat" -require "enju_leaf/expire_editable_fragment" -require "enju_leaf/expire_fragment_cache" require "enju_leaf/import_file" +require "enju_leaf/export_file" require "enju_leaf/localized_name" require "enju_leaf/master_model" require "enju_leaf/url_validator" require 'csv' @@ -34,60 +33,60 @@ def render_403 return if performed? if user_signed_in? respond_to do |format| - format.html {render :template => 'page/403', :status => 403} - format.mobile {render :template => 'page/403', :status => 403} - format.xml {render :template => 'page/403', :status => 403} - format.json { render :text => '{"error": "forbidden"}' } + format.html {render template: 'page/403', status: 403} + format.mobile {render template: 'page/403', status: 403} + format.xml {render template: 'page/403', status: 403} + format.json { render text: '{"error": "forbidden"}' } end else respond_to do |format| format.html {redirect_to new_user_session_url} format.mobile {redirect_to new_user_session_url} - format.xml {render :template => 'page/403', :status => 403} - format.json { render :text => '{"error": "forbidden"}' } + format.xml {render template: 'page/403', status: 403} + format.json { render text: '{"error": "forbidden"}' } end end end def render_404 return if performed? respond_to do |format| - format.html {render :template => 'page/404', :status => 404} - format.mobile {render :template => 'page/404', :status => 404} - format.xml {render :template => 'page/404', :status => 404} - format.json { render :text => '{"error": "not_found"}' } + format.html {render template: 'page/404', status: 404} + format.mobile {render template: 'page/404', status: 404} + format.xml {render template: 'page/404', status: 404} + format.json { render text: '{"error": "not_found"}' } end end def render_404_invalid_format return if performed? - render :file => "#{Rails.root}/public/404", :formats => [:html] + render file: "#{Rails.root}/public/404", formats: [:html] end def render_500 Rails.logger.fatal("please confirm that the Solr is running.") return if performed? #flash[:notice] = t('page.connection_failed') respond_to do |format| - format.html {render :file => "#{Rails.root.to_s}/public/500", :layout => false, :status => 500} - format.mobile {render :file => "#{Rails.root.to_s}/public/500", :layout => false, :status => 500} - format.xml {render :template => 'page/500', :status => 500} - format.json { render :text => '{"error": "server_error"}' } + format.html {render file: "#{Rails.root.to_s}/public/500", layout: false, status: 500} + format.mobile {render file: "#{Rails.root.to_s}/public/500", layout: false, status: 500} + format.xml {render template: 'page/500', status: 500} + format.json { render text: '{"error": "server_error"}' } end end def set_locale if params[:locale] unless I18n.available_locales.include?(params[:locale].to_s.intern) raise InvalidLocaleError end end if user_signed_in? - locale = params[:locale] || session[:locale] || current_user.locale.try(:to_sym) + locale = params[:locale] || session[:locale] || current_user.profile.try(:locale).try(:to_sym) else locale = params[:locale] || session[:locale] end if locale I18n.locale = @locale = session[:locale] = locale.to_sym @@ -97,20 +96,20 @@ rescue InvalidLocaleError @locale = I18n.default_locale end def default_url_options(options={}) - {:locale => nil} + {locale: nil} end def set_available_languages if Rails.env == 'production' @available_languages = Rails.cache.fetch('available_languages'){ - Language.where(:iso_639_1 => I18n.available_locales.map{|l| l.to_s}).select([:id, :iso_639_1, :name, :native_name, :display_name, :position]).all + Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s}).select([:id, :iso_639_1, :name, :native_name, :display_name, :position]).all } else - @available_languages = Language.where(:iso_639_1 => I18n.available_locales.map{|l| l.to_s}) + @available_languages = Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s}) end end def reset_params_session session[:params] = nil @@ -123,11 +122,11 @@ def access_denied raise CanCan::AccessDenied end def get_user - @user = User.where(:username => params[:user_id]).first if params[:user_id] + @user = User.where(username: params[:user_id]).first if params[:user_id] #authorize! :show, @user if @user end def get_user_group @user_group = UserGroup.find(params[:user_group_id]) if params[:user_group_id] @@ -181,11 +180,11 @@ carrier_type = params[:carrier_type] library = params[:library] language = params[:language] if defined?(EnjuSubject) subject = params[:subject] - subject_by_term = Subject.where(:term => params[:subject]).first + subject_by_term = Subject.where(term: params[:subject]).first @subject_by_term = subject_by_term end search.build do with(:publisher_ids).equal_to agent.id if agent @@ -282,10 +281,10 @@ def move_position(resource, direction, redirect = true) if ['higher', 'lower'].include?(direction) resource.send("move_#{direction}") if redirect - redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore) + redirect_to url_for(controller: resource.class.to_s.pluralize.underscore) return end end end end