Edit a comment in its association showBest way to add comments in erbPassing params between link_to and render partialundefined method `comments' for nil:NilClass NoMethodError in Activities#indexHow to associate a user with a comment?Rails radio button: set default value based on model / database entryBootstrap modal window errorHow do I render my JS erb?How to update has_many :through association with strong parameters in Rails 4Ruby on Rails - Adding comments to postWhy is this object creating without an ID value and therefore not saving it self?

Can I turn my anal-retentiveness into a career?

The Digit Triangles

Is it necessary to use pronouns with the verb "essere"?

Pre-mixing cryogenic fuels and using only one fuel tank

A variation to the phrase "hanging over my shoulders"

What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?

Do we have to expect a queue for the shuttle from Watford Junction to Harry Potter Studio?

Quoting Keynes in a lecture

Doesn't the system of the Supreme Court oppose justice?

Does "he squandered his car on drink" sound natural?

Does the Linux kernel need a file system to run?

What is the difference between lands and mana?

Why do Radio Buttons not fill the entire outer circle?

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

Why does Carol not get rid of the Kree symbol on her suit when she changes its colours?

Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Shouldn’t conservatives embrace universal basic income?

Microchip documentation does not label CAN buss pins on micro controller pinout diagram

What is going on with gets(stdin) on the site coderbyte?

What (the heck) is a Super Worm Equinox Moon?

Giving feedback to someone without sounding prejudiced

It grows, but water kills it

Why Shazam when there is already Superman?



Edit a comment in its association show


Best way to add comments in erbPassing params between link_to and render partialundefined method `comments' for nil:NilClass NoMethodError in Activities#indexHow to associate a user with a comment?Rails radio button: set default value based on model / database entryBootstrap modal window errorHow do I render my JS erb?How to update has_many :through association with strong parameters in Rails 4Ruby on Rails - Adding comments to postWhy is this object creating without an ID value and therefore not saving it self?













0















I have a Concert model and Comment model



The user directly write his comments in the concert show, but for any reasons he may want to edit it...



What is the easiest way to do this? I don't want to go to the edit view, but I'd rather prefer to edit it in the show page...



How or can I use the same form that I have in that show?



I was thinking of a modal but I am not sure it's friendy user...



Any help would be very welcome



concerts/show.html.erb



<h1><%= @concert.kountry%> - <%= @concert.city %> - <%= @concert.venue %> </h1>

<% @concert.comments.each do |c| %>
<%= c.user.email %>
<%= l(c.created_at, format: '%d/%m/%y - %H:%M:%S') %> - <%= link_to "Modifier", edit_concert_comment_path(c) %>
<%= simple_format(c.content) %>
<% end %>


<%= simple_form_for([@concert, @comment]) do |f| %>
<%= f.input :content, as: :text, placeholder: "your comment", label: false, input_html: rows: 3 %>
<%= f.submit "Send", class: "btn btn-success" %>
<% end %>









share|improve this question




























    0















    I have a Concert model and Comment model



    The user directly write his comments in the concert show, but for any reasons he may want to edit it...



    What is the easiest way to do this? I don't want to go to the edit view, but I'd rather prefer to edit it in the show page...



    How or can I use the same form that I have in that show?



    I was thinking of a modal but I am not sure it's friendy user...



    Any help would be very welcome



    concerts/show.html.erb



    <h1><%= @concert.kountry%> - <%= @concert.city %> - <%= @concert.venue %> </h1>

    <% @concert.comments.each do |c| %>
    <%= c.user.email %>
    <%= l(c.created_at, format: '%d/%m/%y - %H:%M:%S') %> - <%= link_to "Modifier", edit_concert_comment_path(c) %>
    <%= simple_format(c.content) %>
    <% end %>


    <%= simple_form_for([@concert, @comment]) do |f| %>
    <%= f.input :content, as: :text, placeholder: "your comment", label: false, input_html: rows: 3 %>
    <%= f.submit "Send", class: "btn btn-success" %>
    <% end %>









    share|improve this question


























      0












      0








      0








      I have a Concert model and Comment model



      The user directly write his comments in the concert show, but for any reasons he may want to edit it...



      What is the easiest way to do this? I don't want to go to the edit view, but I'd rather prefer to edit it in the show page...



      How or can I use the same form that I have in that show?



      I was thinking of a modal but I am not sure it's friendy user...



      Any help would be very welcome



      concerts/show.html.erb



      <h1><%= @concert.kountry%> - <%= @concert.city %> - <%= @concert.venue %> </h1>

      <% @concert.comments.each do |c| %>
      <%= c.user.email %>
      <%= l(c.created_at, format: '%d/%m/%y - %H:%M:%S') %> - <%= link_to "Modifier", edit_concert_comment_path(c) %>
      <%= simple_format(c.content) %>
      <% end %>


      <%= simple_form_for([@concert, @comment]) do |f| %>
      <%= f.input :content, as: :text, placeholder: "your comment", label: false, input_html: rows: 3 %>
      <%= f.submit "Send", class: "btn btn-success" %>
      <% end %>









      share|improve this question
















      I have a Concert model and Comment model



      The user directly write his comments in the concert show, but for any reasons he may want to edit it...



      What is the easiest way to do this? I don't want to go to the edit view, but I'd rather prefer to edit it in the show page...



      How or can I use the same form that I have in that show?



      I was thinking of a modal but I am not sure it's friendy user...



      Any help would be very welcome



      concerts/show.html.erb



      <h1><%= @concert.kountry%> - <%= @concert.city %> - <%= @concert.venue %> </h1>

      <% @concert.comments.each do |c| %>
      <%= c.user.email %>
      <%= l(c.created_at, format: '%d/%m/%y - %H:%M:%S') %> - <%= link_to "Modifier", edit_concert_comment_path(c) %>
      <%= simple_format(c.content) %>
      <% end %>


      <%= simple_form_for([@concert, @comment]) do |f| %>
      <%= f.input :content, as: :text, placeholder: "your comment", label: false, input_html: rows: 3 %>
      <%= f.submit "Send", class: "btn btn-success" %>
      <% end %>






      ruby-on-rails






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 0:58









      Antarr Byrd

      9,9672372126




      9,9672372126










      asked Mar 7 at 23:47









      mariemarie

      635




      635






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can try using the Best In Place gem, hasn't been updated in a while but should still work.



          modify form



          <% @concert.comments.each do |comment| %>
          <%= comment.user.email %>
          <%= l(comment.created_at, format: '%d/%m/%y - %H:%M:%S') %>
          <%= best_in_place(comment, :content, as: :textarea) %>
          <% end %>


          then modify controller



          def update
          @comment = Comment.find params[:id]

          respond_to do |format|
          if @comment.update(update_comment_params)
          format.html redirect_to(@comment, notice: 'Comment was successfully updated.')
          format.json respond_with_bip(@comment)
          else
          format.html render action: "edit"
          format.json respond_with_bip(@comment)
          end
          end
          end





          share|improve this answer

























          • Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

            – marie
            Mar 8 at 10:33












          • What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

            – Antarr Byrd
            Mar 8 at 16:05











          • I do this in the concerts controller

            – marie
            Mar 9 at 15:43










          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%2f55054626%2fedit-a-comment-in-its-association-show%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














          You can try using the Best In Place gem, hasn't been updated in a while but should still work.



          modify form



          <% @concert.comments.each do |comment| %>
          <%= comment.user.email %>
          <%= l(comment.created_at, format: '%d/%m/%y - %H:%M:%S') %>
          <%= best_in_place(comment, :content, as: :textarea) %>
          <% end %>


          then modify controller



          def update
          @comment = Comment.find params[:id]

          respond_to do |format|
          if @comment.update(update_comment_params)
          format.html redirect_to(@comment, notice: 'Comment was successfully updated.')
          format.json respond_with_bip(@comment)
          else
          format.html render action: "edit"
          format.json respond_with_bip(@comment)
          end
          end
          end





          share|improve this answer

























          • Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

            – marie
            Mar 8 at 10:33












          • What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

            – Antarr Byrd
            Mar 8 at 16:05











          • I do this in the concerts controller

            – marie
            Mar 9 at 15:43















          0














          You can try using the Best In Place gem, hasn't been updated in a while but should still work.



          modify form



          <% @concert.comments.each do |comment| %>
          <%= comment.user.email %>
          <%= l(comment.created_at, format: '%d/%m/%y - %H:%M:%S') %>
          <%= best_in_place(comment, :content, as: :textarea) %>
          <% end %>


          then modify controller



          def update
          @comment = Comment.find params[:id]

          respond_to do |format|
          if @comment.update(update_comment_params)
          format.html redirect_to(@comment, notice: 'Comment was successfully updated.')
          format.json respond_with_bip(@comment)
          else
          format.html render action: "edit"
          format.json respond_with_bip(@comment)
          end
          end
          end





          share|improve this answer

























          • Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

            – marie
            Mar 8 at 10:33












          • What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

            – Antarr Byrd
            Mar 8 at 16:05











          • I do this in the concerts controller

            – marie
            Mar 9 at 15:43













          0












          0








          0







          You can try using the Best In Place gem, hasn't been updated in a while but should still work.



          modify form



          <% @concert.comments.each do |comment| %>
          <%= comment.user.email %>
          <%= l(comment.created_at, format: '%d/%m/%y - %H:%M:%S') %>
          <%= best_in_place(comment, :content, as: :textarea) %>
          <% end %>


          then modify controller



          def update
          @comment = Comment.find params[:id]

          respond_to do |format|
          if @comment.update(update_comment_params)
          format.html redirect_to(@comment, notice: 'Comment was successfully updated.')
          format.json respond_with_bip(@comment)
          else
          format.html render action: "edit"
          format.json respond_with_bip(@comment)
          end
          end
          end





          share|improve this answer















          You can try using the Best In Place gem, hasn't been updated in a while but should still work.



          modify form



          <% @concert.comments.each do |comment| %>
          <%= comment.user.email %>
          <%= l(comment.created_at, format: '%d/%m/%y - %H:%M:%S') %>
          <%= best_in_place(comment, :content, as: :textarea) %>
          <% end %>


          then modify controller



          def update
          @comment = Comment.find params[:id]

          respond_to do |format|
          if @comment.update(update_comment_params)
          format.html redirect_to(@comment, notice: 'Comment was successfully updated.')
          format.json respond_with_bip(@comment)
          else
          format.html render action: "edit"
          format.json respond_with_bip(@comment)
          end
          end
          end






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 at 4:26

























          answered Mar 8 at 4:19









          Antarr ByrdAntarr Byrd

          9,9672372126




          9,9672372126












          • Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

            – marie
            Mar 8 at 10:33












          • What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

            – Antarr Byrd
            Mar 8 at 16:05











          • I do this in the concerts controller

            – marie
            Mar 9 at 15:43

















          • Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

            – marie
            Mar 8 at 10:33












          • What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

            – Antarr Byrd
            Mar 8 at 16:05











          • I do this in the concerts controller

            – marie
            Mar 9 at 15:43
















          Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

          – marie
          Mar 8 at 10:33






          Thank you Antarr, it says undefined method comment_path for #<#<Class:0x007fa799a19120>:0x007fa79a84fd48> Did you mean? concert_path on this line ` <%= best_in_place(comment, :content, as: :textarea) %>`

          – marie
          Mar 8 at 10:33














          What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

          – Antarr Byrd
          Mar 8 at 16:05





          What controller do you currently use to update/create comment? What's the out put of running rails routes in the console?

          – Antarr Byrd
          Mar 8 at 16:05













          I do this in the concerts controller

          – marie
          Mar 9 at 15:43





          I do this in the concerts controller

          – marie
          Mar 9 at 15:43



















          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%2f55054626%2fedit-a-comment-in-its-association-show%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

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived