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.

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0f7aa11a00f7a07a00e83fc6167dae38%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to