Paperclip: NoMethodError (undefined method `match' for nil:NilClass) - ruby

I've looked all over the internet trying to find why this error is happening to me.
I'm trying to upload a file using paperclip gem in Rails 3.2.7 and is giving me this error:
NoMethodError in ItemsController#create
undefined method `match' for nil:NilClass
Rails.root: C:/Users/AC_37-PC_BH/RubymineProjects/railstutorial-sample_app_2nd_ed-815d98a
app/controllers/items_controller.rb:20:in `new'
app/controllers/items_controller.rb:20:in `create'
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"oYc/V2xKpJVKXPukjrjzQJAboOxI27YXPI42sfDHYaA=",
"item"=>{"item_name"=>"",
"item_pic"=>#<ActionDispatch::Http::UploadedFile:0x3c36678 #original_filename="197623_10150112121221032_1900156_n.jpg",
#content_type="image/jpeg",
#headers="Content-Disposition: form-data; name=\"item[item_pic]\"; filename=\"197623_10150112121221032_1900156_n.jpg\"\r\nContent-Type: image/jpeg\r\n",
#tempfile=#<File:C:/Users/AC_37-~1/AppData/Local/Temp/RackMultipart20120801-6096-q8c9v0>>},
"commit"=>"Create my account"}
I'm including a github to the project so you guys can test it. And try to see what's wrong.
You have to manually access the localhost:3000/items/new to see the page
https://github.com/vinchbr/demo_app
All help would be much appreciated =)

You need to put into Gemfile:
The following code:
gem 'paperclip', '3.0.4'

Related

`find_value': undefined method `each' for nil:NilClass (NoMethodError) while parsing response

I'm calling a SOAP method using savon 2.11.2 and ruby 2.4.1p111
I get that error:
C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/nori-2.6.0/lib/nori.rb:72:in `find_value': undefined method `each' for nil:NilClass (NoMethodError)
from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/nori-2.6.0/lib/nori.rb:38:in `find'
from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/savon-2.11.2/lib/savon/soap_fault.rb:36:in `message_by_version'
from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/savon-2.11.2/lib/savon/soap_fault.rb:25:in `to_s'
from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.3.0/lib/sensu-plugin/cli.rb:65:in `message'
from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.3.0/lib/sensu-plugin/cli.rb:65:in `rescue in block in <class:CLI>'
from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.3.0/lib/sensu-plugin/cli.rb:55:in `block in <class:CLI>'
when calling:
client.call(:get_integration_events_request, message: request(system, actual_page))
I don't get that error every time only for a specific response, only thing i can see different on that response is it has CDATA and new lines inside one of the fields
I called same SOAP using SOAPUI and parse the output using nori
parser = Nori.new
parser.parse(
and it parse without any issue, but SAVON is clearly failing to parse the response before I can do anything
I tried to change default parser from nokogiri to rexml with same result

NoMethodError - undefined method `now' for Watir::Time:Class

I get the following error anytime I try to interact with a Watir element.
/Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/wait/timer.rb:40:in `current_time': undefined method `now' for Watir::Time:Class (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/wait/timer.rb:6:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/elements/element.rb:656:in `new'
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/elements/element.rb:656:in `element_call'
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/elements/element.rb:114:in `click'
from fund_cc.rb:8:in `<main>'
Here is my code:
require 'watir'
# require 'time'
b = Watir::Browser.new(:chrome)#, :url => "http://localhost:9515")
b.goto "https://www.bankofamerica.com/"
contact_us= b.link(:text, "Contact Us")
contact_us.click
Does anyone know how to resolve this?
This should be fixed in version 6.0.2.
From Titus Fortner on the Watir-General mailing list:
The latest version of Watir attempts to use monotomic time where
supported and it looks like we grabbed the wrong Time class for where
it is not supported.
I just updated and pushed the fix to 6.0.2. You should be able to just
bundle update now.
I was able to reproduce this behavior. You can monkey patch your gem locally by tweaking the current_time method in /lib/watir/wait/timer.rb:
def current_time
::Time.now.to_f # was Time.now.to_f
end
And I'd suggest logging an issue on https://github.com/watir/watir/issues.

Ruby / Sinatra - Route any HTTP request to HTTPS (using Rack::SSL) - !! Invalid request

I'm playing with Ruby / Sinatra at present and attempting to get HTTPS working.
I've taken a look at the rack:ssl gem here: https://github.com/josh/rack-ssl
It seems to be working when I run the application (as in redirecting to HTTPS), but nothing is displayed in the browser and the log comes up with the following error:
!! Invalid request
#!/usr/bin/env ruby
require 'rack/ssl'
require 'sinatra'
use Rack::SSL
get '/' do
'Hello World'
end
I'm not sure what to do from here.
Update:
Turned Thin Logging on in the sinatra app and got the following in the log:
!! Invalid request
Invalid HTTP format, parsing fails.
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/thin-1.5.1/lib/thin/request.rb:82:in `execute'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/thin-1.5.1/lib/thin/request.rb:82:in `parse'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-1.4.3/lib/sinatra/base.rb:1408:in `run!'
/Users/ashleycox/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-1.4.3/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'
Any help would be greatly appreciated, thank you.

Digest::MD5 in Ruby 1.9.3

I'm running into something weird here.
I have an "authenticator" that relies on ND5 to hash a certain string we match as password. The problem when I run my tests is this:
NoMethodError: undefined method `md5' for #<CASServer::Authenticators::Billing:0x007fd8e6c906a0>
./models/authenticators/billing.rb:63:in `validate'
./routes/login.rb:166:in `block (2 levels) in <class:Server>'
./routes/login.rb:158:in `each'
./routes/login.rb:158:in `block in <class:Server>'
(eval):2:in `click_button'
./features/step_definitions/when_steps.rb:32:in `/^I enter "(.*)" as username and the generated username password and log in$/'
./features/rubycas.login.feature:14:in `When I enter "username" as username and the generated username password and log in'
So basically he does not recognize the MD5 as part of the Digest library.
This problem occurs when running the tests in the IDE, as well as in the IRB console:
1.9.3-p125 :001 > require "digest/md5" and Digest::MD5("test")
NoMethodError: undefined method `MD5' for Digest:Module
However, when I run the following:
[root#DCUDEV01 /home/morn/rubycas/current]# ruby
require "digest/md5" and Digest::MD5("test")
I receive no errors, dumps or exceptions. Ruby just accepts it.
What am I missing in order to get this MD5 stuff working?
Digest::MD5 is not a method but a module. Try
Digest::MD5.digest("test")
I found it confusing, it doesn't seem like .digest is correct. I can't say it is wrong either...
Commenter #reconbot got it right, IMO, but I saw the comment only after coming back to improve this QA, I think a comment isn't visible enough.
http://ruby-doc.org/stdlib-2.4.0/libdoc/digest/rdoc/Digest/MD5.html
Below is an example usage for md5 hasing for gibbon usage, the mailchimp gem.
md5_hashed_email_address = Digest::MD5.hexdigest("john.doe#example.com")

Error with Rack fetching session-based cookie

My web app is using Rack 1.4.0, Sinatra v1.2.6, Thin v1.2.11, Ruby v1.9.2p180
Navigating to a page I get this error in the log:
TypeError - can't convert nil into String:
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `hexdigest'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `generate_hmac'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:109:in `unpacked_cookie_data'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:99:in `extract_session_id'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:43:in `load_session_id!'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:32:in `[]'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:262:in `current_session_id'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:268:in `session_exists?'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:107:in `exists?'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:122:in `load_for_read!'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:59:in `[]'
/var/www/phrogz.net/routes/test.rb:8:in `logged_in?'
The code in test.rb line 8 is:
session[ :foo ] == "BAR"
Any suggestions on what to upgrade/downgrade to fix this?
Looks like you run into this issue. The fix is in Rack 1.4.1 so simply upgrading should fix it.

Resources