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?
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
add a comment |
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
add a comment |
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
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
ruby-on-rails
edited Mar 8 at 0:58
Antarr Byrd
9,9672372126
9,9672372126
asked Mar 7 at 23:47
mariemarie
635
635
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
Thank you Antarr, it says undefined methodcomment_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 runningrails routes
in the console?
– Antarr Byrd
Mar 8 at 16:05
I do this in the concerts controller
– marie
Mar 9 at 15:43
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%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
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
Thank you Antarr, it says undefined methodcomment_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 runningrails routes
in the console?
– Antarr Byrd
Mar 8 at 16:05
I do this in the concerts controller
– marie
Mar 9 at 15:43
add a comment |
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
Thank you Antarr, it says undefined methodcomment_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 runningrails routes
in the console?
– Antarr Byrd
Mar 8 at 16:05
I do this in the concerts controller
– marie
Mar 9 at 15:43
add a comment |
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
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
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 methodcomment_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 runningrails routes
in the console?
– Antarr Byrd
Mar 8 at 16:05
I do this in the concerts controller
– marie
Mar 9 at 15:43
add a comment |
Thank you Antarr, it says undefined methodcomment_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 runningrails 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
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%2f55054626%2fedit-a-comment-in-its-association-show%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