last day (15 days later) » 

4:26 PM
4
A: Search format in rails not as per expected?

Kirti Thorat.pluck(:from, :invoice) returns an array of arrays. So, @poapps looks something like : [["Snehpandya", "fegd620"],["Snehpandya", "bvnp1442"]] which is why when you do <%= poapp %>, you get output as an array ["Snehpandya", "fegd620"] To display it in snehpandya fegd62 format, change index.htm...

 
undefined method `join' for "fegd620":String ..this what i get
 
Copy the code exactly. Don't merge it with Baloo's answer.
 
i have edited my question have a look
 
See my updated answer.
 
Thanks kirti but i can only see the invoice ..from is not displaying
Done thanks alot
 
4:26 PM
Glad to help :)
 
hi can you please help me for this question
0
Q: How to retrive data from foreign key?

SNEH PANDYAI have 2 models emp requisition emp has_many requisitions requisition belongs_to emp In my console: Requisition Load (1.0ms) SELECT "requisitions".*FROM"requisitions" WHERE "requisitions"."emp_id" = $1 [["emp_id", 3]]=> #<ActiveRecord::Associations::CollectionProxy [#<Requisition id: 7,...

 
hii
@SNEHPANDYA On which line you are getting that output
 
inside the model
 
R u there?
Change
 
sory for late rpl
 
4:33 PM
                            <%= e.requisitions.map do |e| %>
                              <%= e.name %>
                              <% end %>
To
                            <% e.requisitions.map do |e| %>
                              <%= e.name %>
                              <% end %>
I removed = from "<% e.requisitions.map do |e| %>"
 
yes i am trying
 
Let me know how it works
 
undefined local variable or method `e' for #<#<Class:0x4ac5038>:0x4acf1f0>
this is the error
 
u r using the same name for both
change it like this
                        <% e.requisitions.map do |requisition| %>
                          <%= requisition.name %>
                          <% end %>
 
i explain you about my question
 
4:37 PM
??
 
model 1 = Emp has_may requisitions
model 2 = Requisition belongs_to Emp
 
now i wants to know which emp has which requsition
i can easily count by @emp.requisition.count
 
so where is the problem?
 
but i cannot know the name, particular etc.. of the requisition of the emp requested
emp = name , particular , cost , total are the fields
sory requisition
requisition = name , particular , cost , total are the fields
 
4:41 PM
ok..so what details you want to display from requisition entries?
 
when i write in console @emp.requisitions it gives me details but not in rails app
all details
 
so where is the problem..m still not getting
     <% e.requisitions.map do |requisition| %>
                      <%= requisition.name %>
                      <% end %>
didn't display the requisition name for u?
You just need to add rest of the fields in the loop..which u want to get displayed...
Like <%= requisition. particular %>
 
undefined local variable or method `e' for #<#<Class:0x4ac5038>:0x2b45a40>
 
U didn't try the code that I shared?
                    <% e.requisitions.map do |requisition| %>
                      <%= requisition.name %>
                      <% end %>
 
look at this link and click on Assets button
 
4:47 PM
ok
 
i want the details inside the model ..only which has been added by that perticular emp
 
Do you have = in <%= requisition.name %>
 
yes
 
do u get any error?
share the changed code
in the chat box
 
i didnt get the error but this is printed
<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_Collecti‌​onProxy_Requisition:0x3cd32c0>
 
4:50 PM
Did you change the code as I suggested
<% e.requisitions.map do |requisition| %>
<%= requisition.name %>
<% end %>
 
yes do i give all my code of page?
 
yes..
 
<div class="container">
<div class="row">
<div class="col-md-9">
<form class = "form-inline" action="#" method="get">
<div class="input-group">
<input type="text" class="form-control" id="system-search" placeholder="Search" name="q" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<div class = "row">
<div class="col-md-9">
<table class="table table-striped table-bordered table-condensed">
 
did u push the changes on heroku?
 
no its still on developemet
 
4:51 PM
what do u see in development..upload a screenshot here
Change the ma to each
<%e.requisitions.each do |requisition| %>
<%= requisition.name %>
<% end %>
 
same error
 
one time u say..u dont get an error just <ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_Collecti‌​‌​onProxy_Requisition:0x3cd32c0> nd one time u say u r getting error
 
aree i get this error when i have written your code
 
Which one is true..be clear..else it will be difficult to debug
and with existing code as
<%e.requisitions.map do |e| %>
you don't get undefined e
?
 
i get undefine
 
4:58 PM
Well u changed the code
I see it now
<% @emp.each do |e| %>
<tr >
<td><%= e.username %></td>
<td><%= e.email %></td>
<td><%= e.sign_in_count %></td>
<td><%= e.current_sign_in_at %></td>
<td><%= e.last_sign_in_at %></td>
<td><%= e.current_sign_in_ip %></td>
<td><%= e.last_sign_in_ip%></td>
<td><button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
<%= e.requisitions.count %> Assets
</button> </td>
</tr> <%end %>
In this part of code
there was no <%end %> before
isko yahi end karega toh neeche e kaise milega
 
yeah muje pata he but me niche add krta hu toh muje sab requisition aa jata he
 
You should end this block after
<%e.requisitions.map do |requisition| %>
<%= requisition.name %>
<% end %>
 
i want only those requisition of which emp added
 
how do u identify the "added emp"
Try this and then tell me with an example what is not working
 
yeah
 
5:02 PM
<div class="container">
<div class="row">
<div class="col-md-9">
<form class = "form-inline" action="#" method="get">
<div class="input-group">
<input type="text" class="form-control" id="system-search" placeholder="Search" name="q" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<div class = "row">
<div class="col-md-9">
<table class="table table-striped table-bordered table-condensed">
 
my code
<div class="container">
<div class="row">
<div class="col-md-9">
<form class = "form-inline" action="#" method="get">
<div class="input-group">
<input type="text" class="form-control" id="system-search" placeholder="Search" name="q" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<div class = "row">
<div class="col-md-9">
<table class="table table-striped table-bordered table-condensed">
out put
when i click on model
every time it shows same out put
 
lemme chec
In tbody
you should add
<tr> and <td>
do that and check
in this part
<tbody>

<%e.requisitions.map do |requisition| %>
<%= requisition.name %>
<% end %>

</tbody>
 
but it shows same every tim
 
Its working rt
 
there are 6assets so it shoud show 6 names
 
5:13 PM
yes
 
when i click on 1asset it shoud show 1 asset
 
try this one min
<tbody>
<tr><td> <%= e.username %> </td><td>
<%e.requisitions.map do |requisition| %>
<%= requisition.name %>
<% end %>
</td></tr>
</tbody>
see if u get diff usernames for 1 asset nd 6 assets
 
nope..every time it take the 1 row only
 
show me the output f this
when u click on 1 asset nd when u click on 6 assets
 
when i click any of the assets it give same output
 
5:20 PM
u see username anil for every record?
 
yes
 
it seems like modal is created only once for the first emp..after that its never updated
 
yeah what is the solution for that
 
hmm... i hv never worked with modals...i won't be of much help there...mebbe u can post a new question giving the scenario n snapshot...someone wid knowledge of modals wud be able to help
 
ok thank you alot ..you help me maximum ..i was not expecting this much help looking to your reputation
really thank you
 
5:32 PM
no problem.. :)
cya..
 

last day (15 days later) »