Ruby on Rails how to print join tables from view?How to use concerns in Rails 4How is attr_accessible used in Rails 4?Rails 4: how to use $(document).ready() with turbo-linksSQL - where queries on join tableRails 4 - Access Join Table Value in viewsRails4 Association autosave does not workGenerate current session's user id into the form in railsShow data from join table ruby on railsNOT NULL constraint failed created_at when saving modelJoin tables with Ruby on Rails 5
What are the words for people who cause trouble believing they know better?
Traffic law UK, pedestrians
Bent spoke design wheels — feasible?
Working in the USA for living expenses only; allowed on VWP?
What's the correct term for a waitress in the Middle Ages?
Personalization conditions switching doesn`t work in Experience Editor (9.1.0, Initial Release)
Avoiding cliches when writing gods
Riley's, assemble!
Responsibility for visa checking
What happens to foam insulation board after you pour concrete slab?
Building a road to escape Earth's gravity by making a pyramid on Antartica
How could a possessed body begin to rot and decay while it is still alive?
How to make thick Asian sauces?
Comma Code - Ch. 4 Automate the Boring Stuff
Metal bar on DMM PCB
Company is asking me to work from overseas, but wants me to take a paycut
Old black and white movie: glowing black rocks slowly turn you into stone upon touch
What is the purpose of building foundations?
If Boris Johnson were prosecuted and convicted of lying about Brexit, can that be used to cancel Brexit?
What do we gain with higher order logics?
Did thousands of women die every year due to illegal abortions before Roe v. Wade?
How much water is needed to create a Katana capable of cutting flesh, bones and wood?
Regarding eBGP Multipath
Is it possible for people to live in the eye of a permanent hypercane?
Ruby on Rails how to print join tables from view?
How to use concerns in Rails 4How is attr_accessible used in Rails 4?Rails 4: how to use $(document).ready() with turbo-linksSQL - where queries on join tableRails 4 - Access Join Table Value in viewsRails4 Association autosave does not workGenerate current session's user id into the form in railsShow data from join table ruby on railsNOT NULL constraint failed created_at when saving modelJoin tables with Ruby on Rails 5
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to make a cases manage system in Ruby on Rails. I have two tables: audit_cases and ra_cases. 'audit_cases' has the columns 'Audit_Charge_Code' (primary key) and 'Client_ID'. 'ra_cases' has the columns 'audit_case_id'(foreign key), 'RA_Charge_Code','RA_Manager','RA_IC','RA_Performer' etc.
I have already join the two tables
model:
class RaCase < ActiveRecord::Base
belongs_to :audit_case
end
class AuditCase < ActiveRecord::Base
self.primary_key = "Audit_Charge_Code"
has_many :ra_cases
end
controller:
def index
@a_cases = AuditCase.includes(:ra_cases).all
end
view:
<% @a_cases.each do |a_case| %>
<tr>
<td><%= a_case.Client_ID %></td>
<td><%= a_case.Audit_Charge_Code %></td>
<td><%= a_case.ra_cases.each do |ra_case| %>
<%= ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %><br>
<% end %>
</td>
</tr>
<% end %>
I expect the output will be:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC502 PCC5020218 PCC5027120
PCC502 PCC5020218 PCC5027121
But the actual output is:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC5027120
PCC5027121
[#<RaCase id: 1, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "GITC", fee: 75000, created_at: "2019-03-21 13:57:03", updated_at: "2019-03-21 13:58:19">, #<RaCase id: 2, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "AP Control", fee: 35000, created_at: "2019-03-21 19:01:07", updated_at: "2019-03-21 19:45:08">, #<RaCase id: 3, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7408", case_type: "GITC", fee: 75000, created_at: "2019-03-21 19:14:41", updated_at: "2019-03-21 19:45:47">]
I was wondering how could I NOT to print the whole data array [#<...>] as a result.
Thank you very much!!
ruby-on-rails-4
add a comment |
I'm trying to make a cases manage system in Ruby on Rails. I have two tables: audit_cases and ra_cases. 'audit_cases' has the columns 'Audit_Charge_Code' (primary key) and 'Client_ID'. 'ra_cases' has the columns 'audit_case_id'(foreign key), 'RA_Charge_Code','RA_Manager','RA_IC','RA_Performer' etc.
I have already join the two tables
model:
class RaCase < ActiveRecord::Base
belongs_to :audit_case
end
class AuditCase < ActiveRecord::Base
self.primary_key = "Audit_Charge_Code"
has_many :ra_cases
end
controller:
def index
@a_cases = AuditCase.includes(:ra_cases).all
end
view:
<% @a_cases.each do |a_case| %>
<tr>
<td><%= a_case.Client_ID %></td>
<td><%= a_case.Audit_Charge_Code %></td>
<td><%= a_case.ra_cases.each do |ra_case| %>
<%= ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %><br>
<% end %>
</td>
</tr>
<% end %>
I expect the output will be:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC502 PCC5020218 PCC5027120
PCC502 PCC5020218 PCC5027121
But the actual output is:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC5027120
PCC5027121
[#<RaCase id: 1, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "GITC", fee: 75000, created_at: "2019-03-21 13:57:03", updated_at: "2019-03-21 13:58:19">, #<RaCase id: 2, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "AP Control", fee: 35000, created_at: "2019-03-21 19:01:07", updated_at: "2019-03-21 19:45:08">, #<RaCase id: 3, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7408", case_type: "GITC", fee: 75000, created_at: "2019-03-21 19:14:41", updated_at: "2019-03-21 19:45:47">]
I was wondering how could I NOT to print the whole data array [#<...>] as a result.
Thank you very much!!
ruby-on-rails-4
Here:<%= a_case.ra_cases.each do |ra_case| %>
, change<%=
to<%
without "="
– Sovalina
Mar 24 at 13:32
add a comment |
I'm trying to make a cases manage system in Ruby on Rails. I have two tables: audit_cases and ra_cases. 'audit_cases' has the columns 'Audit_Charge_Code' (primary key) and 'Client_ID'. 'ra_cases' has the columns 'audit_case_id'(foreign key), 'RA_Charge_Code','RA_Manager','RA_IC','RA_Performer' etc.
I have already join the two tables
model:
class RaCase < ActiveRecord::Base
belongs_to :audit_case
end
class AuditCase < ActiveRecord::Base
self.primary_key = "Audit_Charge_Code"
has_many :ra_cases
end
controller:
def index
@a_cases = AuditCase.includes(:ra_cases).all
end
view:
<% @a_cases.each do |a_case| %>
<tr>
<td><%= a_case.Client_ID %></td>
<td><%= a_case.Audit_Charge_Code %></td>
<td><%= a_case.ra_cases.each do |ra_case| %>
<%= ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %><br>
<% end %>
</td>
</tr>
<% end %>
I expect the output will be:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC502 PCC5020218 PCC5027120
PCC502 PCC5020218 PCC5027121
But the actual output is:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC5027120
PCC5027121
[#<RaCase id: 1, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "GITC", fee: 75000, created_at: "2019-03-21 13:57:03", updated_at: "2019-03-21 13:58:19">, #<RaCase id: 2, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "AP Control", fee: 35000, created_at: "2019-03-21 19:01:07", updated_at: "2019-03-21 19:45:08">, #<RaCase id: 3, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7408", case_type: "GITC", fee: 75000, created_at: "2019-03-21 19:14:41", updated_at: "2019-03-21 19:45:47">]
I was wondering how could I NOT to print the whole data array [#<...>] as a result.
Thank you very much!!
ruby-on-rails-4
I'm trying to make a cases manage system in Ruby on Rails. I have two tables: audit_cases and ra_cases. 'audit_cases' has the columns 'Audit_Charge_Code' (primary key) and 'Client_ID'. 'ra_cases' has the columns 'audit_case_id'(foreign key), 'RA_Charge_Code','RA_Manager','RA_IC','RA_Performer' etc.
I have already join the two tables
model:
class RaCase < ActiveRecord::Base
belongs_to :audit_case
end
class AuditCase < ActiveRecord::Base
self.primary_key = "Audit_Charge_Code"
has_many :ra_cases
end
controller:
def index
@a_cases = AuditCase.includes(:ra_cases).all
end
view:
<% @a_cases.each do |a_case| %>
<tr>
<td><%= a_case.Client_ID %></td>
<td><%= a_case.Audit_Charge_Code %></td>
<td><%= a_case.ra_cases.each do |ra_case| %>
<%= ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %><br>
<% end %>
</td>
</tr>
<% end %>
I expect the output will be:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC502 PCC5020218 PCC5027120
PCC502 PCC5020218 PCC5027121
But the actual output is:
ClientID AuditChargeCode RAChargeCode
PCC502 PCC5020218 PCC5027119
PCC5027120
PCC5027121
[#<RaCase id: 1, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "GITC", fee: 75000, created_at: "2019-03-21 13:57:03", updated_at: "2019-03-21 13:58:19">, #<RaCase id: 2, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7572", case_type: "AP Control", fee: 35000, created_at: "2019-03-21 19:01:07", updated_at: "2019-03-21 19:45:08">, #<RaCase id: 3, audit_case_id: "PCC5020218", RA_Charge_Code: "PCC5027119", RA_Manager: "7829", RA_IC: "7687", RA_Performer: "7408", case_type: "GITC", fee: 75000, created_at: "2019-03-21 19:14:41", updated_at: "2019-03-21 19:45:47">]
I was wondering how could I NOT to print the whole data array [#<...>] as a result.
Thank you very much!!
ruby-on-rails-4
ruby-on-rails-4
asked Mar 24 at 13:21
ChipmunkwuChipmunkwu
62
62
Here:<%= a_case.ra_cases.each do |ra_case| %>
, change<%=
to<%
without "="
– Sovalina
Mar 24 at 13:32
add a comment |
Here:<%= a_case.ra_cases.each do |ra_case| %>
, change<%=
to<%
without "="
– Sovalina
Mar 24 at 13:32
Here:
<%= a_case.ra_cases.each do |ra_case| %>
, change <%=
to <%
without "="– Sovalina
Mar 24 at 13:32
Here:
<%= a_case.ra_cases.each do |ra_case| %>
, change <%=
to <%
without "="– Sovalina
Mar 24 at 13:32
add a comment |
1 Answer
1
active
oldest
votes
The reason you are printing the entire data array is because you are using the <%= %>
format. This format prints its results. You will need to use the <% %>
format, which doesn't print its results:
<% ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324225%2fruby-on-rails-how-to-print-join-tables-from-view%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The reason you are printing the entire data array is because you are using the <%= %>
format. This format prints its results. You will need to use the <% %>
format, which doesn't print its results:
<% ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %>
add a comment |
The reason you are printing the entire data array is because you are using the <%= %>
format. This format prints its results. You will need to use the <% %>
format, which doesn't print its results:
<% ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %>
add a comment |
The reason you are printing the entire data array is because you are using the <%= %>
format. This format prints its results. You will need to use the <% %>
format, which doesn't print its results:
<% ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %>
The reason you are printing the entire data array is because you are using the <%= %>
format. This format prints its results. You will need to use the <% %>
format, which doesn't print its results:
<% ra_case.RA_Charge_Code %> <%= ra_case.RA_Performer %>
answered Mar 24 at 15:32
hashrockethashrocket
931716
931716
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324225%2fruby-on-rails-how-to-print-join-tables-from-view%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Here:
<%= a_case.ra_cases.each do |ra_case| %>
, change<%=
to<%
without "="– Sovalina
Mar 24 at 13:32