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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page