Request w/ new tab or window

2 views
Skip to first unread message

Jeffrey Taylor

unread,
Mar 19, 2021, 11:21:26 AM3/19/21
to pad...@googlegroups.com

I formerly had this in a template:

    <h2 class="card-title"><%= link_to(@post.name, @post.url, target: '_blank') %></h2>

I now need to send a request (GET is fine) to the server and open @post.url in a new window/tab.  I changed the template code to:

<h2 class="card-title"> <%= link_to(@post.name, url_for(:post, :read, id: @post.id) %></h2>

and the server code:

  get :read, '/post/:id/read' do
    post = Post.with_pk! params[:id]
    post.click!
    post.save(changed: true)

    redirect post.url, target: '_blank'
  end

This opens @post.url in the same tab/window.  How do I get it opened in a separate window?

TIA,
   Jeffrey


Reply all
Reply to author
Forward
0 new messages