Colin Law wrote in post #1181947:
> On 6 March 2016 at 08:00, Naveed Alam <li...@ruby-forum.com> wrote:
>>    @employee = Employee.find(params[:id])
>>     if request.post? and @rosterduty.save
>>       flash[:notice] =  t('flash7')
>>       redirect_to :controller => "employee", :action => "add_rosterduty"
>>     end
>> end
>>
>> and below is the view, where I want to call method from the Employee
>> model, method name is full_name which says full_name undefined.
>
> Can you copy/paste the full error message please.
>
> Colin

NoMethodError in Employee#add_rosterduty

Showing app/views/employee/add_rosterduty.html.erb where line #5 raised:

undefined method `full_name' for nil:NilClass
Extracted source (around line #5):

2:   <%= show_header_icon %>
3:   <h1><%= "Roster Duty" %></h1>
4:   <div class='header-sep'>|</div>
5:   <div class='sub-header'><%= @employee.full_name %></div>
6:
7: </div>
8: <div id="page-yield">
RAILS_ROOT: D:/Ansi/fed343_new

Application Trace | Framework Trace | Full Trace
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in
 
`method_missing'
D:/Ansi/fed343_new/app/views/employee/add_rosterduty.html.erb:5:in 
`_run_erb_app47views47employee47add_rosterduty46html46erb'
D:/Ansi/fed343_new/app/controllers/application_controller.rb:361:in 
`render'
Request

Parameters:

{"id"=>"2"}

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@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/1effe453cce6f53c0581a65d10e93c0a%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to