Rails 3.1.3 - backtrace_silencers initializer file error - ruby-on-rails-3

I added the following like to the backtrace_silencers initializer file:
Rails.backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') }
I get the following error message in my rails server when an exception occurs:
Error during failsafe response: wrong argument type Pathname (expected
Regexp) .../config/initializers/backtrace_silencers.rb:2:in `gsub'
Which is odd b/c gsub is used as an example here:
http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html
Any idea what's going on?

Try
Rails.backtrace_cleaner.add_filter { |line| line.gsub(Rails.root.to_s, '') }

Related

Alamofire multipartFormData.append method raise Fatal error: Call of deleted method

I am using Alamofire and I use Alamofire for the http request and uploading image to the server.
Normally, I use simple http request, but today I checked uploading request.
I got the "Fatal error: Call of deleted method" and App was crashed.
This is my code.
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(imageData, withName: "image", fileName: "user_image", mimeType: "image/png")
if let params = params {
for (key, value) in params {
// This method raise "Fatal error: Call of deleted method"
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
}
}, to: path, encodingCompletion: { result in
})
The next code does not raise the error.
multipartFormData.append(imageData, withName: "image", fileName: "user_image", mimeType: "image/png")
But this code raise the error which said "Fatal error: Call of deleted method".
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
Before today, this code did not raise the error.
I tried these.
First, I upgraded Alamofire 4.7.2 to 4.7.3.
But the result was same.
Second, This codes are defined in embedded frameworks, so I copy this method to App code directory.
But the result was same.
Environment
XCode 9.4.1
Carthage 0.30.1 to install Alamofire
I solved this problem.
I reinstalled XCode and Simulator, and fixed the problem.
I referenced these links.
How to Uninstall Xcode on macOS
xcode simulator not coming up - reinstall possible?

why chef-metal-ssh is failed

I was trying to follow https://github.com/double-z/chef-metal-ssh
I'm running the code below, it throws the exception:
[2015-01-19T06:03:39-06:00] ERROR: machineone had an error: ArgumentError: wrong number of arguments (2 for 0)
require 'chef_metal_ssh'
name = "one"
with_ssh_cluster("~/metal_ssh")
machine name do
action [:ready, :converge]
machine_options 'ip_address' => '10.62.56.209',
'ssh_options' => {
'user' => 'root',
'keys' => ['/home/chefuser/test.rsa']
}
files '/remote/path.txt' => { :content => 'foo' }
end
machine_execute name do
command "pwd" # this uses new_daemon_key to register with halo
end
I want to know what's wrong of this code. And I don't understand for with_ssh_cluster("~/metal_ssh") what content should be in "~/metal_ssh"? thanks.
I had to dig a little with the code to understand (I'm not using it).
According to the comment below found here
# cluster_path - path to the directory containing the vagrant files,
# which should have been created with the vagrant_cluster resource.
The "~/metal_ssh" file should be the Vagrantfile path.
chaf-metal-ssh is a driver for chef-metal, I'm not sure you're comfortable with chef-metal, so I would advise starting by reading This and This
I've found that the issue is I was using chef 12.0.3, and in line 109 of /usr/local/rvm/gems/ruby-2.0.0-p598/gems/chef-12.0.3/lib/chef/dsl/recipe.rb
resource.load_prior_resource(type, name)
But in chef-metal-ssh-0.1.2/lib/chef/resource/ssh_cluster.rb:18
it's defined as
def load_prior_resource
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
end
so it throws
ArgumentError: wrong number of arguments (2 for 0)

Authenticating the cobrand

I created a new developer account and I am having a problem authenticating with the REST API.
POST https://rest.developer.yodlee.com/services/srest/restserver/v1.0/authenticate/coblogin
{ cobrandLogin: 'sbCob*****',
cobrandPassword: '**********' }
the system responds with:
{ Error: [ { errorDetail: 'Internal Core Error has occurred' } ] }
am I doing something wrong?
I am testing the API with Postman and apparently I need to send the params with x-www-form-urlencoded to make it work. Using the default form-data lead to the above mentioned error.
In my case, this was solved by changing the content-type as per http://developer.yodlee.com/Aggregation_API/Aggregation_Services_Guide/Aggregation_REST_API_Reference
require 'rest-client'
module Yodlee
def self.login_to_yodlee
site = self.site_resource
login_hash = {
cobrandLogin: 'yourlogin',
cobrandPassword: 'yourpassword'
}
begin
response = site["/authenticate/coblogin"].post login_hash, :'content-type' => 'application/x-www-form-urlencoded'
puts response
rescue RestClient::ResourceNotFound => ex
raise Exception.new(ex.response)
rescue Exception => ex
raise Exception.new(ex)
end
end
def self.site_resource
RestClient::Resource.new('https://rest.developer.yodlee.com/services/srest/restserver/v1.0')
end
end
Yodlee.login_to_yodlee
Generally, this error comes when you do not provide the input parameter's name correctly; while in this mentioned code above I could see that both of them are correct. I'd suggest you to please double check the input parameter name(case sensitive) as well properly. And just to mention you should be sending it as two different parameters i.e., 'cobrandLogin' and cobrandPassword.

Fatal error on Mink WebAssert.textPageContains when assertion fails

I'm using Behat\Mink\Driver\Selenium2Driver. This is the #Then function for one of my features:
/**
* #Then /^I should see "([^"]*)"$/
*/
public function iShouldSee($result)
{
$verification = new WebAssert($this->session);
try
{
$verification->pageTextContains($result);
}
catch(ResponseTextException $e)
{
printf("something went wrong");
}
}
If I write a scenario where the assertion should pass, I have no problem: it runs properly and creates the output file in junit format that I will pass to Jenkins later.
But if I change the scenario so it should fail, the execution is interrupted after the failed assertion text and I get this message:
Then I should see "my text" # MyCompany\MyBDDBundle\Features\Context\FeatureContext::iShouldSee()
The text "my text" was not found anywhere in the text of the current page.
PHP Fatal error: Call to a member function text() on a non-object in C:\BitNami\wampstack-5.4.15-0\frameworks\symfony\vendor\behat\mink-selenium2-driver\src\Behat\Mink\Driver\Selenium2Driver.php on line 464
Fatal error: Call to a member function text() on a non-object in C:\BitNami\wampstack-5.4.15-0\frameworks\symfony\vendor\behat\mink-selenium2-driver\src\Behat\Mink\Driver\Selenium2Driver.php on line 464
I've been looking the Selenium2Driver.php file and line 464 is inside function getText($xpath) that I just don't use.
And finally, having the test been interrupted, the junit file that is created as an output only contains the XML header, although there were many passed scenarios.
<?xml version="1.0" encoding="UTF-8"?>
Why is the test working when the assertion passes but it crashes when it fails?

CakePHP 2.0 + Notice (8): Undefined index: Upload [APP/Controller/UploadsController.php, line 32]

Im using 000webhost as a way to host my portfolio of websites. However Im getting this error thrown in which doesn't happen to me on localhost.
Notice (8): Undefined index: Upload [APP/Controller/UploadsController.php, line 32]
This is the code it seems to be referring to,
public function add() {
$this->render();
if($this->request->is('post')){
$file = $this->request->data['Upload']['file'];
if($this->Upload->save($this->data) && move_uploaded_file($file['tmp_name'],APP.'webroot/files/uploads'.DS.$this->Upload->id.'.mp4'))
{
$this->Session->setFlash('<p class="uploadflash">The upload has been saved</p>', true);
$this->redirect(array('controller'=>'Uploads', 'action' => 'watch', $this->Upload->id));
} else {
$this->Session->setFlash('<p class="loginerror">The upload could not be saved, mp4 files can be saved only.</p>', true);
}
}
}
Any ideas as to why this is happening?
Also in addition my Elements are not showing up on this online hosting either?
I get thrown this error on the page
Element Not Found: Elements/uploads/recentuploads.ctp
Does anyone else seem to have this problem??
Upon further inspection I have found that the server does not allow file upload sizes to exceed 2mb, in this instance PHP throws the error above.