Dear Experts/Friends

I created a model for and moved it to a sub folder in my model's
directory.

Then wrote in the existing controller named employee the below code to
add roster duty.

def add_rosterduty()
   @rosterduty = RosterDuty.new()
   @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.


********  add_rosterduty.html.erb ***********

<div id="page-yield">
  <div class="bread_crumb">
    <%=make_breadcrumb%>
    <%=render_breadcrumbs%>
  </div>

  <% form_for(@rosterduty) do |a| %>
    <%= error_messages_for  :rosterduty %>
    <div id="admission1_form">

      <div id="necessary-field-notification"> <%= t('legend1') %> <span
class="necessary-field">*</span> <%= t('legend2') %></div>
      <span class="span-sub-heading"><%= t('general_details') %></span>
      <hr class="sub-heading"></hr>
      <div class="label-field-pair">
         <div class="text-input-bg">
           <%= a.hidden_field :employee_id, :value => params([:id]) %>
         </div>
      </div>
      <hr class="label-underline"></hr>

      <div class="label-field-pair">
        <label for="employee_name"><%= "Duty name:" %></label>
        <div class="text-input-bg"><%= a.text_field :duty_name %></div>
      </div>
      <hr class="label-underline"></hr>
    <div class="label-field-pair">
        <label for="employee_name"><%= "Duty place:" %></label>
        <div class="text-input-bg"><%= a.text_field :duty_place %></div>
      </div>
      <hr class="label-underline"></hr>
    <div class="label-field-pair">
        <label for="employee_name"><%= "Day first:" %></label>
        <div class="text-input-bg"><%= a.text_field :duty_day1 %></div>
      </div>
      <hr class="label-underline"></hr>
    <div class="label-field-pair">
        <label for="employee_name"><%= "Day last:" %></label>
        <div class="text-input-bg"><%= a.text_field :duty_day2 %></div>
      </div>
      <hr class="label-underline"></hr>
    <div class="label-field-pair">
        <label for="employee_name"><%= "Day time:" %></label>
        <div class="text-input-bg"><%= a.text_field :duty_time %></div>
      </div>
      <hr class="label-underline"></hr>
    <div class="label-field-pair">
        <label for="employee_name"><%= "Employee id:" %></label>
        <div class="text-input-bg"><%= a.text_field :employee_id
%></div>
      </div>
      <hr class="label-underline"></hr>

  <%= submit_tag "► #{t('save_and_proceed')}", :class =>
"submit_button", :disable_with => "► #{t('please_wait')}" %>
<% end %>
</div>


******** Method in employee model ********
def full_name
    "#{first_name} #{middle_name} #{last_name}"
  end


Pls help, thanks in advance.

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

Reply via email to