Ruby on Rails Sunday, March 6, 2016

On 6 March 2016 at 11:08, Naveed Alam <lists@ruby-forum.com> wrote:
>>
>> There is not much point putting the log line after the line that is
>> causing processing to stop due to the error. Also there is not much
>> point putting it anywhere in that bit of code as we already know (from
>> the error message) that it is nil. I expected that you would put it
>> in the area where you are setting up @employee to try to work out why
>> it is nil.
>>
>> Colin
>
> if u mean like the below, I did and the development log is the same
>
> def add_rosterduty
> @rosterduty = RosterDuty.new()
> @employee = Employee.find(params[:id])
> logger.info( "Employee: #{@employee.inspect}")

That line should insert a line into the log when it is executed. Are
you sure it is not there? Try
logger.info( "Employee: #{@employee.inspect}
*******************************************")
so that it will be easy to see. If it is still not there then that
suggests it is not executing that method at all. Are you sure you are
editting the right file. Do a global search in your editor for
add_rosterduty and make sure you have not defined it in more than one
place.

> if request.post? and @rosterduty.save
> flash[:notice] = t('flash7')
> redirect_to :controller => "employee", :action => "add_rosterduty"
> end
> end

I don't see that it is related to this problem, but I notice from the
log that you are doing a GET on add_rosterduty when I think it should
be a post. Also it seems a bit odd that you make a new RosterDuty and
save it without setting any data in it. Again though, that is not the
cause of the problem you are seeing at the moment.

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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsYdQLRu1oY%2BU_Rzq8j4T%2BHY-yy-jQW4VL3S4Wdx%3D-aUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment