no method for nill class

11 views
Skip to first unread message

fugee ohu

unread,
Apr 20, 2017, 7:30:31 PM4/20/17
to Ruby on Rails: Talk
In the snippet below,the last line causes the error; :showdate is whitelisted, it's components appear just in the params list returned by the browser The error's at the plus sign but not sure which of them

    @showday = params["showdate(3i)"]
    showmonth_string = params["showdate(2i)"]
    @showmonth = Date::MONTHNAMES[showmonth_string.to_i]
    @showyear = params["showdate(1i)"]
    @showdate = @showmonth + " " + @showday + ", " + @showyear

Colin Law

unread,
Apr 21, 2017, 4:30:09 AM4/21/17
to Ruby on Rails: Talk
As I believe I have suggested to you before, first level simple
debugging can be done using logger.info, so in this case if you insert
before the last line something like

logger.info "Show date: #{@showmonth}, #{@showday}, #{@showyear}"

then you will see in the terminal what values those variables have.

Colin

Mugurel Chirica

unread,
Apr 21, 2017, 5:50:46 AM4/21/17
to rubyonra...@googlegroups.com
Another very good option is to learn to use a debugger (that can help you a lot until you learn Ruby / Rails better, but it can be useful then as well), is to have a look at Pry https://github.com/deivid-rodriguez/pry-byebug or for ruby 1.9.3 https://github.com/nixme/pry-debugger.

You will need maybe 1-2 hours to set it up and learn to use it, but after that you will get answer to questions like the above in a few seconds or minutes depending on the problem.

Cheers

Colin Law

unread,
Apr 21, 2017, 6:55:22 AM4/21/17
to Ruby on Rails: Talk
On 21 April 2017 at 10:22, Mugurel Chirica <chirica...@gmail.com> wrote:
> Another very good option is to learn to use a debugger (that can help you a
> lot until you learn Ruby / Rails better, but it can be useful then as well),
> is to have a look at Pry https://github.com/deivid-rodriguez/pry-byebug or
> for ruby 1.9.3 https://github.com/nixme/pry-debugger.

+1 to that.

Colin

Hassan Schroeder

unread,
Apr 21, 2017, 10:38:59 AM4/21/17
to rubyonrails-talk
On Fri, Apr 21, 2017 at 2:22 AM, Mugurel Chirica
<chirica...@gmail.com> wrote:
> Another very good option is to learn to use a debugger

Another +1 for Pry -- absolutely an essential tool.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote
Reply all
Reply to author
Forward
0 new messages