Thomas Connolly


50 Experience
0 Lessons Completed
0 Questions Solved


Posted in Solving FizzBuzz in Ruby Discussion

I tried the second solution and got an error "no implicit conversion of Fixnum into String" when using rails c with Pry; and NoMethodError: undefined method 'blank?' for String:Class when using irb:

tom@thomas:~/paul$ irb
2.3.1 :001 > 1.upto(100) do |i|
2.3.1 :002 > str = ""
2.3.1 :003?>
2.3.1 :004 > str += "Fizz" if i % 3 == 0
2.3.1 :005?> str += "Buzz" if i % 5 == 0
2.3.1 :006?> str += i if str.blank?
2.3.1 :007?>
2.3.1 :008 > puts str
2.3.1 :009?> end
NoMethodError: undefined method `blank?' for "":String
from (irb):6:in `block in irb_binding'
from (irb):1:in `upto'
from (irb):1

What am I doing wrong?

Posted in Setup Ubuntu 16.04 Xenial Xerus Discussion

Chris, as a subscriber, I've gotten a lot of tips from you, now here's one from me:
It should be "without further ado", not "adieu." The former means fuss and bother, the latter means goodbye. The are homonyms.

For a second time I find it necessary to withdraw a question/problem. I doubled checked my csv file and found that that was where the problem lay. I was able to dispense with the merge by conforming the dates in the csv to Y-m-d, then I didn't have to use strptime or strftime on nil fields. I made that adjustment and used :anniversary and :birthday as regular columns, as they had the proper format.

I'm really bummed I can't make this work! Here's where I added the converters:
CSV.foreach(file.path, headers: true, header_converters: :symbol, converters: :all) do |row|

Everything but the dates for birthdays and anniversaries was loading correctly, so I know things are wired correctly. The dates are wrong, so I added the converters: :all to correct the dates. That didn't work.
Then I was told via stackoverflow I have to use .merge when using the strptime language so now my self.assign_from_row looks like this:
def self.assign_from_row(row)
member = Member.where(membership_id: row[:membership_id]).first_or_initialize
member.assign_attributes row.to_hash.slice(
:last_name, :first_name, :email).merge(:anniversary => Date.strptime(row[:anniversary],

As you can see, the csv has month/day/year, but what is sent to the db is Y/m/d, and the m and d are switched, so I need to specify the correct parsing.
When it run it in the console I get "no implicit conversion of nil into String" Many of our church members are widows or widowers, so the field for anniversary will be nil for many.

I've looked at a hundred csv and/or string questions on SO, and every thing I try does not work for me. Is there something really really basic that I'm missing? I'm not a developer and the only Rails app I have created is a single website for my church. I'm a retired writer/editor; 74 years old, so be gentle, please. I appreciate any time you can spare! Thanks.

Chris, I'm having trouble figuring out how to convert the date field in my csv file (mdY) to the proper format. It's reading the Y correctly, but importing the day to month and vice-versa instead of day to day and month to month. Where should the code be put and what does it look like? I tried a bunch of things and just can't get it to work. I looked at smarter_csv and thought that might be the answer, but it didn't work for me.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.