How to get rid of email regex message on Devise? - ruby-on-rails-4

I'm using Devise Token Auth gem and, everytime I run my test suite in Rails 4.2.5 app, I'm getting this deprecation warning from Devise:
DEPRECATION WARNING: [Devise] config.email_regexp will have a new default on Devise 4.1
To keep the current behavior please set in your config/initializers/devise.rb the following:
Devise.setup do |config|
config.email_regexp = /\A[^#\s]+#([^#\s]+\.)+[^#\W]+\z/
end
If you want to use the new default:
Devise.setup do |config|
config.email_regexp = /\A[^#\s]+#[^#\s]+\z/
end
. (called from block in tsort_each at /usr/local/lib/ruby/2.2.0/tsort.rb:226)
I've already added config/initializers/devise.rb file manually and have set email_regex as suggested by the message above, but the annoying message persists.
How can I disable this message?

Related with this post, you can manage deprecation warnings according to th environment in which you are working, as said in rails guides:
active_support.deprecation_behavior Sets up deprecation reporting for
environments, defaulting to :log for development, :notify for
production and :stderr for test. If a value isn't set for
config.active_support.deprecation then this initializer will prompt
the user to configure this line in the current environment's
config/environments file. Can be set to an array of values.
So just change in config/environments/test.rb the value :stderr for :log
Rails.application.configure do
...
# Print deprecation notices to the stderr.
config.active_support.deprecation = :log
...
end
And with this the depecation warning will be in the log/test.log instead in the console output

Related

Flutter Xcode Error Undefined symbol: _MDFInsetsFlippedHorizontally and Undefined symbol: _MDFRectFlippedHorizontally

I am struggling with these for days. Searching for answers online but still to no avail.
Details of the error:
List of pod files: (I assume this is related to MDFInternationalisation?)
This is my code in podfile:
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
I tried this solution https://github.com/material-components/material-components-ios/issues/10203 but error still persists. I also tried installing the latest xcode version.
Please please help me. I have been stucked for days and it is extremely frustrating. I am a flutter dev so I am quite a noob in ios. Hope to get any guidance. Thank you!
After trying out multiple solutuions, this is my solution. Simply add this pod 'MDFInternationalization','~>2.0 to your podfile, nothing more. There are some solutions on the internet that require us to change post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) end end It is not required. just add pod md internationalisation and make sure you specify 2.0.
After that, pod install, flutter clean and flutter run.

ember serve and browser reload results in "cannot GET /foo" with custom Ember.Location

TL;DR: Added custom location type to environment.js then ember serve -> open browser to route /foo -> cannot GET /foo
Followed the instructions at https://www.emberjs.com/api/classes/Ember.Location.html#toc_custom-implementation and copied the code exactly as it appeared into a file called app/locations/history-url-logging.js, added a line to config/environment.js that said:
ENV.locationType = 'history-url-logging';
For reference, the code given in the docs is simply:
import Ember from 'ember';
export default Ember.HistoryLocation.extend({
implementation: 'history-url-logging',
pushState: function (path) {
console.log(path);
this._super.apply(this, arguments);
}
});
I decided to restart the server, did the usual CTRL+C to ember s then did ember s again. I went back to my browser sitting on one of the routes, hit F5, and received the cryptic error:
Cannot GET /contacts
So, after MUCH Googling and trial and error (and posting a previous question here which I just edited with this text you're reading), I discovered that to FIX that error, all I had to do remove the config line ENV.locationType = 'history-url-logging';, restart the server (ember s), and suddenly the app worked fine!
What's even more odd is that if I start the app without that line in environment.js, then once the app is running (and the browser window reloads just fine, etc), then I re-add the line that says ENV.locationType = 'history-url-logging'; (which triggers a live reload), and the app still works fine! (E.g. hitting F5 to reload the page doesn't vie me the "Cannot GET /contacts" (or whatever the route is) error.) And, of course, the console gives me the "console.log" output as expected from the code above.
So, long and short of it, using a custom location totally seems to screw up ember serve - which is really sad and frustrating! Any ideas how to fix this?
Ember built-in server looks at the environment.js locationType property to figure out if it must serve routes after the rootURL path. By default, if the locationType is history it will do it. It uses string matching.
In your case you wrote your own location, inheriting from HistoryLocation therefor the locationType property in the environement.js is now history-url-logging. The built-in server doesn't recognize it as a history based form of location just by the name. It will default to hash location. It doesn't analyze your code.
For this scenario, we have to help the built-in server to understand that the locationType is equivalent to a history location.
You need to add historySupportMiddleware: true in your environment.js file right after the locationType property.

YAML parsing error in Travis CI, but not locally

I'm using Travis CI for a gem I'm developing and ran into a strange error (links are at the end of the question).
The gem is storing some information serialized with YAML which isn't built manually, but using YAML.dump and later loaded again with YAML.load.
The following lines are used to dump and load a hash to/from YAML:
headers[:ar_mailer_settings] = YAML.dump(settings)
...
ar_settings = YAML.load(mail['ar_mailer_settings'].value)
The later line seems to be producing an error on Travis CI, but when I run the tests locally using the same binary versions, everything runs perfectly fine:
Psych::SyntaxError: (<unknown>): mapping values are not allowed in this context at line 1 column 22
/home/travis/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/psych.rb:205:in `parse'
...
/home/travis/build/Stex/ar_mailer_revised/lib/action_mailer/ar_mailer.rb:84:in `deliver!'
I put a simple puts into the deliver! method to see if there would be a difference in the stored values, and it seems that Travis CI is ignoring newlines in the generated YAML which then causes a parse error:
Travis:
"--- smtp_settings: :address: localhost :port: 25 :domain: localhost.localdomain :user_name: some.user :password: some.password :authentication: :plain :enable_starttls_auto: true "
Locally:
"---\nsmtp_settings:\n :address: localhost\n :port: 25\n :domain: localhost.localdomain\n :user_name: some.user\n :password: some.password\n :authentication: :plain\n :enable_starttls_auto: true\n"
Interestingly, I didn't change anything regarding these methods before the Travis CI was failing, so I'm not sure if I'm simply overlooking something here or if it's some kind of incompatibility issue.
Can I do something to preserve the newline characters?
Edit: Additional Information
The gem allows setting custom SMTP settings and attributes for single email records.
These can be set directly when generating the email in an ActionMailer::Base instance see here for a dummy mailer
To transport these custom settings to ActionMailer's deliver!-method which actually creates a new email record, I serialize these settings via YAML, save them in the email header temporarily and restore them later see ar_mailer_setting and deliver! here
The source code which raises the error: here
The complete Travis CI output: here
If more information is needed, please let me know and I'll add it to the question.
Thanks in advance!

How do I get SQL logging in Rails 4 WEBrick for a non-development environment?

I'm using Rails 4.1.2. I have some environments which are exact copies of my development environment. In other words, I created them by simply copying config/environments/development.rb to a file with a different name (e.g., destaging.rb). They differ only in the connection information in database.yml.
If I issue RAILS_ENV=destaging rails s or rails s -e destaging at the command line, everything works just as I desire, except that I get no SQL logging to STDOUT, which is a bummer.
Since my destaging environment is absolutely identical to my development environment except for different connection settings in database.yml, I suspect that something is looking for an environment named development and enabling SQL logging to STDOUT only if an environment with that name is active. How can I enable SQL logging to STDOUT for other environments launched through WEBRick?
For posterity, I've discovered how to do this. First, I'm running Ruby 2.1.2 with Rails 4.1.2. If that is not your environment, your mileage may vary, though I suspect the solution will be very similar.
So, first you must modify bin/rails. Open this file and change it as follows. (I have posted the entire file, minus the shebang, for clarity.)
begin
load File::expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
# Here comes the important part
require 'rails/commands/server'
class Rails::Server::Options
def parse_with_logging!(args)
options = parse_without_logging!(args)
options[:log_stdout] = true # Or whatever condition you want
options
end
alias_method_chain :parse!, :logging
end
require 'rails/commands'
Since require 'rails/commands' executes the server immediately, monkey-patching after that line does not work. It is simply ignored. If you try to monkey-patch it before you require the commands, it explodes because the Rails::Server::Options class has not yet been defined. Thus, we have to pre-emptively require rails/commands/server so we can alias its parse! method.
Monkey-patching should almost always be a last resort, IMHO. However, I see no alternative in this case. If anyone has a better idea, I'd love to hear it.
I also encountered this problem with the same versions of Rails and Ruby, using a non-standard environment name (in your case "destaging"). However I did not want it to affect all environments, nor lose any more time to not getting work done, so I simply changed the way I start the server:
(tail -F log/destaging.log &) && rails s
Then afterwards to restart the server, ctrl-c as usual and then rails s again. The tail will keep going in the background and for all intents and purposes the experience will be like it was before this stopped working.

magento Not valid template file /page/1column.phtml

I had my site running fine on the devp. server. After I migrated the app to my production server. Everything worked until I added an extension and enabled it. The site still works but the product view page doesn't show up. Everytime I click on the product view page, this error is appended to my log file...
CRIT (2): Not valid template file:frontend/base/default/template/page/1column.phtml
I have checked the file it is alright, just same as the one working on the development server. I've tried disabling the only plugin (custom menu) that I have and still the problem persists. I've tried increasing memory_limit but it doesn't help either.
Please help, I am stuck in the middle of nothing.
A common cause of this error is the use of symlinks without enabling this in the admin area…
System > configuration > developer > Template Settings
The error gets triggered in app\code\core\Mage\Core\Block\Template.php around line 243 ( see here ) - so if its not an issue with symlinks then this would be a good place to start debugging.
If you are not using xDebug then where the exception gets caught around line 250 you should either log or var_dump the values of:
$includeFilePath
and
$this->_viewDir
Then make sure they both exist (paying attention to the case)
Failing that you might want to look at permissions.
UPDATE core_config_data SET value = '1' WHERE path = 'dev/template/allow_symlink';
or
INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0, 'dev/template/allow_symlink', '1');