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;








0















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!!










share|improve this question






















  • Here: <%= a_case.ra_cases.each do |ra_case| %>, change <%= to <% without "="

    – Sovalina
    Mar 24 at 13:32

















0















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!!










share|improve this question






















  • Here: <%= a_case.ra_cases.each do |ra_case| %>, change <%= to <% without "="

    – Sovalina
    Mar 24 at 13:32













0












0








0








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!!










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















0














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 %>





share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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 %>





    share|improve this answer



























      0














      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 %>





      share|improve this answer

























        0












        0








        0







        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 %>





        share|improve this answer













        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 %>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 15:32









        hashrockethashrocket

        931716




        931716





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript