Invalid date notation: nil! Adyen Rails Gem Error - ruby-on-rails

I'm looking to integrate my rails application with the payment provider Adyen, I've installed the Adyen Gem and put the code in to make a basic form, but I'm getting an error:
Adyen Gem: http://github.com/wvanbergen/adyen
Invalid date notation: nil!
/Users/chris/.gem/ruby/1.8/gems/adyen-0.1.5/lib/adyen/formatter.rb:10:in
fmt_date'
/Users/chris/.gem/ruby/1.8/gems/adyen-0.1.5/lib/adyen/form.rb:35:in
do_attribute_transformations!'
/Users/chris/.gem/ruby/1.8/gems/adyen-0.1.5/lib/adyen/form.rb:40:in
payment_fields'
/Users/chris/.gem/ruby/1.8/gems/adyen-0.1.5/lib/adyen/form.rb:59:in
hidden_fields'
app/views/payments/free.html.erb:7
my Code is:
<% form_tag(:url => Adyen::Form.url) do %>
<%= Adyen::Form.hidden_fields(:merchant_account => 'myaccount',:skin_code => 'myperfectskin', :shared_secret => 'youllneverguess', :payment_amount => '1000') %>

If you look at the Adyen's source, you'll see on lib/adyen/form.rb at the line 35 that there's a ship_before_date required option which you don't fill.
But you're using Adyen at it's version 0.1.5 when there's the 0.2.1 version (and apparently that "bug" has been corrected).
If you installed that version (with gem install adyen -v=0.2.1), you would be using a much more recent and reliable version of the library.

Related

"no implicit conversion of nil into String"in the Search Module of Redmine

On the redmine of my company, there is this bug where I get an internal error if I want to search into a project.
Here is the log corresponding to the error:
Processing by SearchController#index as HTML
Parameters: {"utf8"=>"✓", "issues"=>"1", "q"=>"test", "id"=>"sprint"}
Current user: me (id=60)
Completed 500 Internal Server Error in 85.0ms
TypeError (no implicit conversion of nil into String):
lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb:126:in `search'
app/controllers/search_controller.rb:74:in `block in index'
app/controllers/search_controller.rb:73:in `each'
app/controllers/search_controller.rb:73:in `index'
The lines corresponding to the error in the controller are :
if !#tokens.empty?
# no more than 5 tokens to search for
#tokens.slice! 5..-1 if #tokens.size > 5
#results = []
#results_by_type = Hash.new {|h,k| h[k] = 0}
limit = 10
#scope.each do |s|
r, c = s.singularize.camelcase.constantize.search(#tokens, projects_to_search,
:all_words => #all_words,
:titles_only => #titles_only,
:limit => (limit+1),
:offset => offset,
:before => params[:previous].nil?)
#results += r
Here is my config :
Environment:
Redmine version 2.6.9.stable
Ruby version 2.3.0-p0 (2015-12-25) [x86_64-linux]
Rails version 3.2.22
Environment production
Database adapter PostgreSQL
SCM:
Git 1.9.1
Filesystem
Redmine plugins:
no plugin installed
What is interesting is that when I search only one letter, i'm redirected on the search page, but I don't have an internal error.
I'm very new to Redmine developpement and to Ruby, I was just assigned to try to fix this bug. Do any of you have an idea of how to fix it ?
Thanks.
I had the same issue, I was able to fix it by downgrading my ruby & rails version, a working set is :
Rails 3.2.19
Ruby 2.1.4p265
It's look like it's due to a braking change in ruby-2.3.0.
It's really odd. We are using 'Redmine' -2.0.3.1 and we do not have that kind of behaviour.
It seems that "someone" messed up the form linked to the search input. Try to follow that data from when you press enter until it answer you with the 500 error code.
If you can , change the environment to development, this way it will show you more detailed errors.
But I can't help you much more , you didn't provide enough info about the problem.

Cannot view issue details after installing Redmine issue-id plugin

I have installed the "issue-id" plugin to Bitnami Redmine 3.1.1 running on Windows Server 2012R2.
Issue Ids have successfully changed for the new ones like "Project-1" on the issue list. (/projects/{Project Name}/issues)
However link URLs to issue details have been broken so I cannot view details for each issue. (I just get the "Internal error" screen as shown on the attached image.)
"production" log file says as follows:
Started GET "/issues/Project-1" for 127.0.0.1 at 2016-01-20 11:00:07
Processing by IssuesController#show as HTML Parameters:
{"id"=>"Project-1"} Current user: jungal (id=1) Rendered
issues/_action_menu.html.erb (34.0ms) Rendered
plugins/redmine_contacts/app/views/deals_issues/_show.html.erb (2.0ms)
Rendered
plugins/redmine_contacts_helpdesk/app/views/issues/_ticket_data.html.erb
(0.0ms) Rendered
plugins/redmine_products/app/views/products_issues/_products.html.erb
(32.0ms) Rendered issues/show.html.erb within layouts/base
(1043.0ms) Completed 500 Internal Server Error in 1632ms
(ActiveRecord: 319.5ms)
ActionView::Template::Error (No route matches {:action=>"new",
:controller=>"journals", :id=>#} missing
required keys: [:id])
77: <% if #issue.description? %>
78: <div class="description">
79: <div class="contextual">
80: <%= link_to l(:button_quote), quoted_issue_path(#issue), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>
81: </div>
82:
83: <p><strong><%=l(:field_description)%></strong></p> app/views/issues/show.html.erb:80:in
_app_views_issues_show_html_erb___574665212_71239980'
app/controllers/issues_controller.rb:118:inblock (2 levels) in show'
app/controllers/issues_controller.rb:115:in show'
lib/redmine/sudo_mode.rb:63:insudo_mode'
I have checked the actual issue id which is number and tried to set the URL like /issues/{number} but it was no use.
Does anybody know how to fix this?
That version of ISSUE-id plugin did not support Redmine 3.x. This was noted on the plugin's page of the official Redmine website and on the official plugin's webpage. Installing such plugin versions on an unsupported Redmine version, unfortunately, means breaking the work of Redmine, like in this case (that's not the only issue you would experience under Redmine 3.x with that version of the plugin).
If the plugin does not support the version of Redmine, that you are using, the only solution is to attempt to find a fork of the plugin, that does support such version (or to ask author to prioritize adding such support). ISSUE-id had such forks. Alternatively, you could check the development version in SVN, which, in theory, could include fixes for such issues already (not released yet). In any way, it's always a good idea to report such issues on the official plugin's page (thus, you could get support from the plugin's community).
P.S. At the moment, the official plugin already supports Redmine 3.x, so this issue is fixed there.

Rails 4.2 syntax error, unexpected ':', expecting =>

I have two computers that I mainly use to develop my Rails application. While working on Computer 1, I added some bootstrap elements to some inputs. For example:
= f.select :transport_from_state, options_for_select(state_populator, #invoice_ambulance.transport_from_state), { include_blank: true}, { class: 'chosen-select', 'data-placeholder': 'State' }
I added the 'data-placeholder': 'State' and used the 'newer' syntax instead of the old :data-placeholder' => 'State' which works fine. The page works with no errors on Computer 1.
I pulled down on computer 2, and now I am getting an error for every instance of 'data-placeholder'. Here is my error:
syntax error, unexpected ':', expecting =>
...en-select', 'data-placeholder': 'State' }
I can replace it with the old syntax and it works fine. However, I shouldn't have to switch 100 instances of this to a deprecated syntax. I have since bundle installed, bundle updated, and rebuilt the db with no luck.
Computer 1 (works)
ruby 2.2.0p0
Rails 4.2.0
Computer 2 (doesnt work)
ruby 2.2.0preview1
Rails 4.2.0
You need to upgrade Computer 2 to the real Ruby 2.2.0 rather than this beta-ish "preview" version you have. Using quoted symbols with the JavaScript-style trailing colon syntax:
{ 'some string': value }
wasn't valid before Ruby 2.2, the 2.2.0preview1 version you have on Computer 2 apparently doesn't support it.
BTW, there is no old and new syntax, there is an alternate JavaScript-style notation that can be use when the keys in a Hash-literal are some symbols. Whoever told you that the hashrocket is deprecated is, at best, confused.
The "newer" syntax is only for symbols.
{hello: 'world'} is equivalent to {:hello => 'world'} but if your key is a string then you still have to use the "hash rocket" syntax: {'hello' => 'world'}
http://ruby-doc.org/core-2.2.0/Hash.html

How to run Ruby on Rails 3 with ruby 2.0

Is there an easy fix, how I could continue an old rails 3-0.20 installation under ruby 2.0?
The first error, caused by this line:
<%= stylesheet_link_tag :all %>
is
ActionView::Template::Error (no implicit conversion of nil into String):
An upgrade of the rails version would be the best, but unfortunately it is not possible in my case.
Hotfix the problem with the following line at the end in application.rb
ActionController::Base.config.relative_url_root = ''
I ran into the same issue. After drilling down into the stylesheet_link_tag method, I found that the issue comes from here
# actionpack-3.0.20/lib/action_view/helpers/asset_tag_helper.rb:749
if has_request && include_host && !source.start_with?(controller.config.relative_url_root)
The problem is String#starts_with?. In 1.9.3, that method will handle a nil as an input. 2.0.0 does not allow that.
ruby-1.9.3> 'whatever'.start_with? nil
=> false
ruby-2.0.0> 'whatever'.start_with? nil
TypeError: no implicit conversion of nil into String
It's probably also true that later versions of Rails set the value to '' if it's not set to prevent this issue. The hotfix mentioned above does fix the issue, but the root cause is differences between 1.9.3 and 2.0.0.

iconv deprecation warning with ruby 1.9.3

I'm getting this warning when I run rspec:
/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require': iconv will be deprecated in the future, use String#encode instead.
I get the same warning with rails 3.1.0, 3.1.1, 3.1.2.rc2 versions. Seems it's related to sqlite3 gem, but I'm not sure. There are no warnings with ruby 1.9.2
Any suggestions how to deal with it?
You are getting this deprecation notice cause a library somewhere is requiring iconv.
iconv is a gem created by Matz that can be used to convert strings from one format to another.
For example this is often used:
Iconv.iconv('UTF-8//IGNORE', 'UTF-8', content) this little bit of magic takes a UTF-8 string that may have invalid chars and converts it to a proper UTF-8 string.
It has been decided that in Ruby 1.9.3 we should not be using iconv any more and instead use the built-in String#encode. encode is more powerful and allows you more flexibility.
The theory is that the above example could be replaced with:
string.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?")
In practice it seems this is imperfect.
This also leads to a less than easy story for gem creators who wish to support 1.8:
content = RUBY_VERSION.to_f < 1.9 ?
Iconv.iconv('UTF-8//IGNORE', 'UTF-8', "content") :
"#{content}".encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace, :replace => '')
So, you have a gem somewhere that is requiring iconv, to find it:
Assuming your error message is: /gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240
Open up /gems/activesupport-3.1.0/lib/active_support/dependencies.rb on line 240:
Add the line:
p caller if file =~ /iconv/
(just after: load_dependency(file) { result = super })
You will get a big fat stack trace:
rake --tasks
/home/sam/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead.
["/home/sam/.rvm/gems/ruby-1.9.3-p125/gems/calais-0.0.13/lib/calais.rb:5:in `'",
.. more omitted ..
This tells me it is the calais gem. Looking through pull requests, I am not the first. The pull has not been yanked in.
Depending on the gem, there may be an upgraded version that does not have this error, so I would recommend you upgrade your gems first. If you are unlucky you may be stuck with the unfortunate task of forking a gem to get rid of this (if for example your pull request to fix it languishes)
If you're seeing this, it's very probably not Rails. If you look at the method surrounding the line being referred to in the error you posted, you'll see the following:
def require(file, *)
result = false
load_dependency(file) { result = super }
result
end
I'm not saying it's your code, necessarily, but I'm certain that it's not actually the line in question where iconv is being called. In my case, I found that my project's code actually contained a reference to iconv.
If you want to check your code for such a reference, try grep -ir iconv ./ in your project directory.
When iconv is actually in a library it can be harder to find. By temporarily changing the above method to:
def require(file, *)
result = false
puts
puts caller.reverse
load_dependency(file) { result = super }
result
end
You can then easily run your code and grep out the relevant lines of the backtrace to find the root cause of the warning.
ruby your/code.rb 2>&1 | grep -B 5 iconv
Add this to the start of your program:
oldverb = $VERBOSE; $VERBOSE = nil
require 'iconv'
$VERBOSE = oldverb
and curse the people who think this is a professional way to handle deprecation.
You can pin down the exact location of the warning by generating exceptions for ActiveSupport::Deprecation, instead of just printing to the log. At the top of application.rb:
ActiveSupport::Deprecation.behavior = Proc.new do |message, backtrace|
raise message
end
Once you've figured out where the warning is coming from (by inspecting the full backtrace), remove this again.
To remove this warning...
go to your .rvm directory and find iconv.c (mine was at ~/.rvm/src/ruby-1.9.3-p125/ext/iconv/iconv.c)
edit that file are remove or comment out the call to warn_deprecated() (should be near the bottom)
from that file's directory, run ruby extconf.rb
then make
then make install
Should do the trick

Resources