vendredi 26 août 2016

In ruby on Rails what should the flow for execute rails application

I am new in Ruby on Rails, I have little bit confusion in Ruby on rails application. I have done all these things

routes.rb

Recruitment::Application.routes.draw do get 'hr/internal_employee_page', controller: 'hr', action: 'internal_employee_page'  get 'hr/permanent_consultant_page' => 'hr#permanent_consultant_page', as: :permanent_consultant_page end 

hr_controller.rb

class HrController < ApplicationController

def internal_employee_page
    @employees = OfferLetter.all
    # render :text => @employees.inspect        
end

def employee_details
    @employees = OfferLetter.all
end

end

_hr_page.html.erb

<%= render 'hr/dashboard'%> <%= render 'hr/internal_employee_page'%>

_internal_employee_page.html.erb

<div id="job_details">
    <%= render "hr/employee_details" %>
</div>

_employee_details.htmlerb

<% @employees.each do |emp| %>
    <h3> Employee Name : <%= emp.full_name %> </h3>
<% end %>

then i got error is : undefined method `each' for nil:NilClass When i did trace then i found hr_controller.rb is not execute, when i commented all hr_controller.rb then I got same error. So please tell me where am i wrong and what is problmes ...

Aucun commentaire:

Enregistrer un commentaire