Adding rows to table in database through forms

15 views
Skip to first unread message

bradford li

unread,
Nov 30, 2014, 4:56:28 AM11/30/14
to rubyonra...@googlegroups.com
I posted a question on stackoverflow:


I am getting an error trying to add rows to my table when I click submit on my form. I am not sure where I am going wrong.

Colin Law

unread,
Nov 30, 2014, 7:10:02 AM11/30/14
to rubyonra...@googlegroups.com
The error shown is

NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/users_controller.rb:32:in `create'

That tells you that you have an object that you something like
variable[..] but the variable is nil. It tells you which line the
problem is on. You need to debug your code to find why that variable
is nil. Often the log in log/development.log can be useful. For very
simple debugging you can insert code such as
puts myvariable.inspect
in, for example, the controller, and that will show the variable in
the server terminal window.

Colin



>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/75782964-5e77-4e82-9ec9-837ac9cebaa2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages