Sha256: 67d65dbc595acd402bab048165a731d1668f843efb1301340265b5bb97e71d99

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

inject_into_file "app/controllers/application_controller.rb", after: "# controller_helpers\n" do
<<-EOF
  skip_before_action :verify_authenticity_token, if: :skip_authenticity?
  before_action :authenticate_user!
  before_action :configure_permitted_parameters, if: :devise_controller?
  after_action :log_current_user

  def log_current_user
    logger.info "Current user: \#{current_user.email}" if current_user
  end

  def redirect_back default_path = :root, options = {}
    redirect_to :back, options
  rescue ActionController::RedirectBackError
    redirect_to default_path, options
  end

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :email
  end

  def skip_authenticity?
    request.format.json? or params[:skip_authenticity]
  end
EOF
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
crosstie-0.0.7 lib/crosstie/templates/controller_helpers.rb
crosstie-0.0.6 lib/crosstie/templates/controller_helpers.rb
crosstie-0.0.5 lib/crosstie/templates/controller_helpers.rb
crosstie-0.0.4 lib/crosstie/templates/controller_helpers.rb
crosstie-0.0.3 lib/crosstie/templates/controller_helpers.rb
crosstie-0.0.2 lib/crosstie/templates/controller_helpers.rb