Hello Roy
I got an NoMethodsError in VisitsController#New and undefined method
‘debug’ for for #VisitsController:0x19b90c8
What I put was
class VisitsController < ApplicationController
def index
end
def show
@visit = Visit.find(params[:id])
end
def new
raise(debug(params))
@visit = Visit.new
#@visit.call_id = params[:call_id]
end
def create
@visit = Visit.new(params[:visit])
if @visit.save
flash[:notice] = “Visit submission succeded”
render :action => ‘show’
else
render :action => ‘new’
end
end
end
And then at the bottom of all the errot stuff I got So I’m not sure if
this is what you want but it does say call_id is 43
which is correct.
Request
Parameters:
{“call_id”=>“43”}
Show session dump
:csrf_id: 06461019879e59311aa06b11eadb68bf
flash: !map:ActionController::Flash::FlashHash {}
Response
I suspect it doesn’t matter, but am not sure. The scaffold-generated
code (for version 2.0.2, which is what I’m using) does a redirect_to,
but I don’t know what informs that choice.
Ach–okay. I didn’t realize debug wasn’t available in a
controller–sorry about that. But no matter–rails’ stock error
handling echoed the params anyway–I think we know now that your link_to
call is successfully moving the call_id. So now we look at the next
step in the chain–your visits/new view. You’ve got to include the
call_id attribute somewhere in your form, so that when it gets posted
back to the server, it (again) gets stuffed into the params[], so your
VisitsController.create method can stuff it into the database.
Looking at the view code you posted earlier in the thread, I’m not
seeing a reference to the call_id. So–within your form_for … end
block throw in a:
<%= f.text_field :call_id %>
That will actually show the call_id attribute–verify that it’s getting
the value you want. If that fixes your problem (and I suspect it will)
then you can change that to
<%= f.hidden_field :call_id %>
And then it won’t be shown to the user, but it will still be part of the
form.
Hello Roy and Good MOrning
Thank YOU so Much!!!
That worked - I figured that the id wasn’t getting passed but I
didn’t know why.
I owe you a deep sense of gratitude and I wish there was a way I
could at least buy you
a BEER or something. Your time and effort are much appreciated. Let
me Know
Thanks again -Owen Madden
I’ll be gone now for a few hours