updated before_filters to before_actions as recommended for rails 4

This commit is contained in:
Niall Paterson 2013-11-17 20:20:22 +00:00 committed by Jonne Haß
parent 244388fcb5
commit f33038f105
28 changed files with 48 additions and 49 deletions

View file

@ -6,13 +6,13 @@ class ApplicationController < ActionController::Base
has_mobile_fu has_mobile_fu
protect_from_forgery :except => :receive protect_from_forgery :except => :receive
before_filter :ensure_http_referer_is_set before_action :ensure_http_referer_is_set
before_filter :set_locale before_action :set_locale
before_filter :set_diaspora_header before_action :set_diaspora_header
before_filter :set_grammatical_gender before_action :set_grammatical_gender
before_filter :mobile_switch before_action :mobile_switch
before_filter :gon_set_current_user before_action :gon_set_current_user
before_filter :gon_set_preloads before_action :gon_set_preloads
inflection_method :grammatical_gender => :gender inflection_method :grammatical_gender => :gender

View file

@ -4,7 +4,7 @@
# #
class AspectMembershipsController < ApplicationController class AspectMembershipsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :html, :json respond_to :html, :json

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class AspectsController < ApplicationController class AspectsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :html, respond_to :html,
:js, :js,

View file

@ -1,5 +1,5 @@
class BlocksController < ApplicationController class BlocksController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :html, :json respond_to :html, :json

View file

@ -4,7 +4,7 @@
class CommentsController < ApplicationController class CommentsController < ApplicationController
include ApplicationHelper include ApplicationHelper
before_filter :authenticate_user!, :except => [:index] before_action :authenticate_user!, :except => [:index]
respond_to :html, respond_to :html,
:mobile, :mobile,

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class ContactsController < ApplicationController class ContactsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
use_bootstrap_for :index, :spotlight use_bootstrap_for :index, :spotlight

View file

@ -4,7 +4,7 @@
# #
class ConversationVisibilitiesController < ApplicationController class ConversationVisibilitiesController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
def destroy def destroy
@vis = ConversationVisibility.where(:person_id => current_user.person.id, @vis = ConversationVisibility.where(:person_id => current_user.person.id,

View file

@ -1,5 +1,5 @@
class ConversationsController < ApplicationController class ConversationsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
layout ->(c) { request.format == :mobile ? "application" : "with_header" } layout ->(c) { request.format == :mobile ? "application" : "with_header" }
use_bootstrap_for :index, :show, :new use_bootstrap_for :index, :show, :new

View file

@ -1,5 +1,5 @@
class InvitationCodesController < ApplicationController class InvitationCodesController < ApplicationController
before_filter :ensure_valid_invite_code before_action :ensure_valid_invite_code
rescue_from ActiveRecord::RecordNotFound do rescue_from ActiveRecord::RecordNotFound do
redirect_to root_url, :notice => "That invite code is no longer valid" redirect_to root_url, :notice => "That invite code is no longer valid"

View file

@ -4,7 +4,7 @@
class InvitationsController < ApplicationController class InvitationsController < ApplicationController
before_filter :authenticate_user!, :only => [:new, :create] before_action :authenticate_user!, :only => [:new, :create]
def new def new
@invite_code = current_user.invitation_code @invite_code = current_user.invitation_code

View file

@ -4,7 +4,7 @@
class LikesController < ApplicationController class LikesController < ApplicationController
include ApplicationHelper include ApplicationHelper
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :html, respond_to :html,
:mobile, :mobile,

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class MessagesController < ApplicationController class MessagesController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :html, :mobile respond_to :html, :mobile
respond_to :json, :only => :show respond_to :json, :only => :show

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class NotificationsController < ApplicationController class NotificationsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" } layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }
use_bootstrap_for :index use_bootstrap_for :index

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class PeopleController < ApplicationController class PeopleController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :last_post] before_action :authenticate_user!, :except => [:show, :last_post]
use_bootstrap_for :index use_bootstrap_for :index

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class PhotosController < ApplicationController class PhotosController < ApplicationController
before_filter :authenticate_user!, :except => :show before_action :authenticate_user!, :except => :show
respond_to :html, :json respond_to :html, :json

View file

@ -5,9 +5,8 @@
class PostsController < ApplicationController class PostsController < ApplicationController
include PostsHelper include PostsHelper
before_filter :authenticate_user!, :except => [:show, :iframe, :oembed, :interactions] before_action :authenticate_user!, :except => [:show, :iframe, :oembed, :interactions]
before_filter :set_format_if_malformed_from_status_net, :only => :show before_action :set_format_if_malformed_from_status_net, :only => :show
before_filter :find_post, :only => [:show, :interactions]
use_bootstrap_for :show use_bootstrap_for :show

View file

@ -3,8 +3,8 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class ProfilesController < ApplicationController class ProfilesController < ApplicationController
before_filter :authenticate_user!, :except => ['show'] before_action :authenticate_user!, :except => ['show']
before_filter -> { @css_framework = :bootstrap }, only: [:show, :edit] before_action -> { @css_framework = :bootstrap }, only: [:show, :edit]
layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:show, :edit] layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:show, :edit]

View file

@ -5,10 +5,10 @@
class PublicsController < ApplicationController class PublicsController < ApplicationController
include Diaspora::Parser include Diaspora::Parser
skip_before_filter :set_header_data skip_before_action :set_header_data
skip_before_filter :set_grammatical_gender skip_before_action :set_grammatical_gender
before_filter :check_for_xml, :only => [:receive, :receive_public] before_action :check_for_xml, :only => [:receive, :receive_public]
before_filter :authenticate_user!, :only => [:index] before_action :authenticate_user!, :only => [:index]
respond_to :html respond_to :html
respond_to :xml, :only => :post respond_to :xml, :only => :post

View file

@ -3,10 +3,10 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class RegistrationsController < Devise::RegistrationsController class RegistrationsController < Devise::RegistrationsController
before_filter :check_registrations_open_or_valid_invite!, :check_valid_invite! before_action :check_registrations_open_or_valid_invite!, :check_valid_invite!
layout ->(c) { request.format == :mobile ? "application" : "with_header" }, :only => [:new] layout ->(c) { request.format == :mobile ? "application" : "with_header" }, :only => [:new]
before_filter -> { @css_framework = :bootstrap }, only: [:new, :create] before_action -> { @css_framework = :bootstrap }, only: [:new, :create]
def create def create
@user = User.build(user_params) @user = User.build(user_params)

View file

@ -1,5 +1,5 @@
class ResharesController < ApplicationController class ResharesController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :json respond_to :json
def create def create

View file

@ -1,5 +1,5 @@
class SearchController < ApplicationController class SearchController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
def search def search
if search_query.starts_with?('#') if search_query.starts_with?('#')

View file

@ -5,10 +5,10 @@ class ServicesController < ApplicationController
# We need to take a raw POST from an omniauth provider with no authenticity token. # We need to take a raw POST from an omniauth provider with no authenticity token.
# See https://github.com/intridea/omniauth/issues/203 # See https://github.com/intridea/omniauth/issues/203
# See also http://www.communityguides.eu/articles/16 # See also http://www.communityguides.eu/articles/16
skip_before_filter :verify_authenticity_token, :only => :create skip_before_action :verify_authenticity_token, :only => :create
before_filter :authenticate_user! before_action :authenticate_user!
before_filter :abort_if_already_authorized, :abort_if_read_only_access, :only => :create before_action :abort_if_already_authorized, :abort_if_read_only_access, :only => :create
before_filter -> { @css_framework = :bootstrap }, only: [:index] before_action -> { @css_framework = :bootstrap }, only: [:index]
layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:index] layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:index]

View file

@ -4,7 +4,7 @@
# #
class ShareVisibilitiesController < ApplicationController class ShareVisibilitiesController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
def update def update
#note :id references a postvisibility #note :id references a postvisibility

View file

@ -3,9 +3,9 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class StatusMessagesController < ApplicationController class StatusMessagesController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
before_filter :remove_getting_started, :only => [:create] before_action :remove_getting_started, :only => [:create]
use_bootstrap_for :bookmarklet use_bootstrap_for :bookmarklet

View file

@ -3,9 +3,9 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class StreamsController < ApplicationController class StreamsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
before_filter :save_selected_aspects, :only => :aspects before_action :save_selected_aspects, :only => :aspects
before_filter :redirect_unless_admin, :only => :public before_action :redirect_unless_admin, :only => :public
respond_to :html, respond_to :html,
:mobile, :mobile,

View file

@ -4,7 +4,7 @@
# #
class TagFollowingsController < ApplicationController class TagFollowingsController < ApplicationController
before_filter :authenticate_user! before_action :authenticate_user!
respond_to :json respond_to :json

View file

@ -3,8 +3,8 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class TagsController < ApplicationController class TagsController < ApplicationController
skip_before_filter :set_grammatical_gender skip_before_action :set_grammatical_gender
before_filter :ensure_page, :only => :show before_action :ensure_page, :only => :show
helper_method :tag_followed? helper_method :tag_followed?

View file

@ -3,8 +3,8 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class UsersController < ApplicationController class UsersController < ApplicationController
before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo] before_action :authenticate_user!, :except => [:new, :create, :public, :user_photo]
before_filter -> { @css_framework = :bootstrap }, only: [:privacy_settings, :edit] before_action -> { @css_framework = :bootstrap }, only: [:privacy_settings, :edit]
layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:privacy_settings, :edit] layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:privacy_settings, :edit]