Colin Law wrote in post #1181949:
> On 6 March 2016 at 09:14, Naveed Alam <
li...@ruby-forum.com> wrote:
>>>> model, method name is full_name which says full_name undefined.
>> Extracted source (around line #5):
>> Application Trace | Framework Trace | Full Trace
>> {"id"=>"2"}
> Error messages are often a little tricky to understand but there is
> often useful information there if the message is considered carefully.
> Note that it is saying undefined method `full_name' for nil:NilClass.
> This means that you have tried to call the method full_name on an
> object that is nil. Looking at the code this means that @employee is
> nil. You need to work out why that is so.
>
> An easy way of doing simple debugging is to insert into your code lines
> such as
>
logger.info( "Employee: #{@employee.inspect} )
> That will insert a line into development.log showing the value of
> @employee.
>
> Colin
Dont know if I am right, but I tried this and the log is below:
<%=
logger.info( "Employee: #{@employee.inspect}") %>
# Logfile created on Sun Mar 06 14:49:25 +0500 2016 [4;36;1mSQL
(0.0ms)[0m [0;1mSET NAMES 'utf8'[0m
[4;35;1mSQL (0.0ms)[0m [0mSET SQL_AUTO_IS_NULL=0[0m
** vote_fu: initialized properly.
** SubdomainFu: initialized properly
[4;36;1mSQL (10.0ms)[0m [0;1mSHOW TABLES[0m
[4;35;1mSQL (0.0ms)[0m [0mSHOW TABLES[0m
[4;36;1mFeeCollectionDiscount Columns (40.0ms)[0m [0;1mSHOW FIELDS
FROM `fee_collection_discounts`[0m
[4;35;1mFeeDiscount Columns (0.0ms)[0m [0mSHOW FIELDS FROM
`fee_discounts`[0m
[4;36;1mRecordUpdate Columns (0.0ms)[0m [0;1mSHOW FIELDS FROM
`record_updates`[0m
[4;35;1mSQL (0.0ms)[0m [0mSET NAMES 'utf8'[0m
[4;36;1mSQL (0.0ms)[0m [0;1mSET SQL_AUTO_IS_NULL=0[0m
Processing EmployeeController#add_rosterduty (for 127.0.0.1 at
2016-03-06 14:50:23) [GET]
Parameters: {"action"=>"add_rosterduty", "id"=>"2",
"controller"=>"employee"}
[4;35;1mUser Columns (2.0ms)[0m [0mSHOW FIELDS FROM `users`[0m
[4;36;1mUser Load (0.0ms)[0m [0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 1) AND (`users`.`is_deleted` = 0) [0m
[4;35;1mConfiguration Columns (1.0ms)[0m [0mSHOW FIELDS FROM
`configurations`[0m
[4;36;1mConfiguration Load (1.0ms)[0m [0;1mSELECT * FROM
`configurations` WHERE (`configurations`.`config_key` = 'Locale') LIMIT
1[0m
[4;35;1mConfiguration Load (0.0ms)[0m [0mSELECT * FROM
`configurations` WHERE (`configurations`.`config_key` =
'InstitutionType') LIMIT 1[0m
[4;36;1mNews Columns (2.0ms)[0m [0;1mSHOW FIELDS FROM `news`[0m
Expired fragment: views/News_latest_fragment (0.0ms)
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM `users` WHERE
(`users`.`id` = 1) AND (`users`.`is_deleted` = 0) [0m
Username : admin Role : Admin
[4;36;1mConfiguration Load (0.0ms)[0m [0;1mSELECT * FROM
`configurations` WHERE (`configurations`.`config_key` =
'StudentAttendanceType') LIMIT 1[0m
[4;35;1mConfiguration Load (0.0ms)[0m [0mSELECT * FROM
`configurations` WHERE (`configurations`.`config_key` =
'AvailableModules') [0m
[4;36;1mUser Load (0.0ms)[0m [0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 1) [0m
[4;35;1mConfiguration Load (0.0ms)[0m [0mSELECT * FROM
`configurations` WHERE (`configurations`.`config_key` =
'FirstTimeLoginEnable') LIMIT 1[0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 1) AND (`users`.`is_deleted` = 0) [0m
[4;35;1mConfiguration Load (1.0ms)[0m [0mSELECT * FROM
`configurations` WHERE (`configurations`.`config_value` = 'HR') LIMIT
1[0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 1) AND (`users`.`is_deleted` = 0) [0m
[4;35;1mprivileges_users Columns (3.0ms)[0m [0mSHOW FIELDS FROM
`privileges_users`[0m
[4;36;1mPrivilege Load (1.0ms)[0m [0;1mSELECT * FROM `privileges`
INNER JOIN `privileges_users` ON `privileges`.id =
`privileges_users`.privilege_id WHERE (`privileges_users`.user_id = 1 )
[0m
[4;35;1mConfiguration Load (0.0ms)[0m [0mSELECT * FROM
`configurations` WHERE (`configurations`.`config_key` =
'PrecisionCount') LIMIT 1[0m
Rendering template within layouts/application
Rendering employee/add_rosterduty
ActionView::TemplateError (undefined method `full_name' for
nil:NilClass) on line #5 of app/views/employee/add_rosterduty.html.erb:
2: <%= show_header_icon %>
3: <h1><%= "Roster Duty" %></h1>
4: <div class='header-sep'>|</div>
5: <div class='sub-header'><%= @employee.full_name %>
6: <%=
logger.info( "Employee: #{@employee.inspect}") %>
7: </div>
8:
app/views/employee/add_rosterduty.html.erb:5
app/controllers/application_controller.rb:361:in `render'
Rendered rescues/_trace (42.0ms)
Rendered rescues/_request_and_response (1.0ms)
Rendering rescues/layout (internal_server_error)