vendredi 30 septembre 2016

How to take value for Object result in ruby on rails

I want to print specific value from object result. here is i am execute SQL query and take all data from View tables, All data coming from "Employee_Information" view(table). hr_controller.rb

class HrController < ApplicationController

  def internal_employee_page        
    @employees = MysqlConnection.connection.select_all("SELECT * FROM Employee_Information")
  end 
end

internal_employee_page.html.erb this is my first view

<div id="job_details">
    <% @employees.each do |emp| %>
        <%= render partial: "hr/employee_details", locals: {emp: emp} %>
    <% end %>               
</div>

_employee_details.html.erb this is my second view

<h3> User Name : <%= emp%> </h3>

like this I am trying to print all value then I got following result enter image description here I want to print each value I tried this also in my second view

<h3> User Name : <%= emp.full_name%> </h3>

But I got Error: enter image description here Please help me I tried every thing according to my knowledge, where am I wrong and what is problems

Aucun commentaire:

Enregistrer un commentaire