On 10 April 2016 at 22:01, David Williams <li...@ruby-forum.com> wrote: > Walter Davis wrote in post #1182743: >>> Should I take a different approach, than hard-coding the show action in >>> the link itself. >> >> You need a different method to render this, or if it will only ever >> appear in the modal, then you need to add layout: false to your >> controller so it doesn't render the whole page. Make sure that your >> `show` template only renders the stuff that will appear within the >> modal, nothing else, and then turn off the layout so you don't get the >> entire page. >> >> If the modals will be the only consumer of the "remote: true" requests, >> then you can make that change in your show controller method, like this: >> >> def show >> #whatever else you regularly have here >> respond_to do |format| >> format.html { } >> format.js { layout: false, template: 'modal' } >> end >> end >> >> Walter > > Thank you for helping me again. I've added a modal.html.erb file. I > included all of the code needed for the modal itself. > > Inside of the show action for the posts_controller.rb > > def show > @post = Post.find(params[:id]) > @new_comment = Comment.build_from(@post, current_user.id, "") > respond_to do |format| > format.html > format.js { render layout: false , template: 'modal'} > format.json {render json: @post } > end > end > > But, for whatever reason, the link_to image_tag button is targeting the > old show.html.erb action for the post.
How can it be targeting code that you have deleted? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLt10HL--4MvMzw5S727U63bU%3D0xJKECBBEH%3DJ4Y4OH0iQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.