Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: rails 4 Flash fixes #55

Merged
merged 1 commit into from
Mar 20, 2018

Conversation

Napolskih
Copy link
Contributor

В рельсах 4.0/4.1 есть проблемы с флешем - пишем символы, читаем строки и тп.
rails/rails#13945

взял версию класса Flash от 4.2, фиксы:
rails/rails@a6ce984
rails/rails@a668bef
rails/rails@3c60fb4

class ApplicationController < ActionController::Base; end

describe ApplicationController, type: :controller do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

env[KEY] = flash_hash.dup
end

if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [123/120]

@app = app
end

def call(env)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cyclomatic complexity for call is too high. [9/6]
Perceived complexity for call is too high. [9/7]


def stringify_array(array)
array.map do |item|
item.kind_of?(Symbol) ? item.to_s : item

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer Object#is_a? over Object#kind_of?.

self[:notice] = message
end

protected

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep a blank line before and after protected.

@flashes.each(&block)
end

alias :merge! :update

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use alias merge! update instead of alias :merge! :update.

flash = case value
when FlashHash # Rails 3.1, 3.2
new(value.instance_variable_get(:@flashes), value.instance_variable_get(:@used))
when Hash # Rails 4.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent when as deep as case.


def self.from_session_value(value)
flash = case value
when FlashHash # Rails 3.1, 3.2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent when as deep as case.

k = k.to_s
@flash[k] = v
@flash.discard(k)
v

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable v used in void context.


# The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed
# to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create
# action that sets <tt>flash[:notice] = "Post successfully created"</tt> before redirecting to a display action that can

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [122/120]

@@ -1,5 +1,5 @@
module Apress
module Utils
VERSION = '2.5.0'.freeze
VERSION = '2.6.0'.freeze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Горячка я считаю, в прод не вышло, а патч огромный

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну ок, патч просто работает только в рельсах >= 4

@Napolskih Napolskih changed the base branch from master to rails-4-support March 20, 2018 04:56
@Napolskih
Copy link
Contributor Author

поменял ветку 🆙

@Napolskih
Copy link
Contributor Author

@abak-press/apress-utils-owners

@Napolskih Napolskih merged commit 3837d43 into abak-press:rails-4-support Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants