Forum: Ruby on Rails form_tag - directing to new target window

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-03-07 21:46
(Received via mailing list)
How do I use...

<%= link_to "All Facilities", :action => 'fac_log_all' %>

if I add :target => "_new"  that is just a parameter and not a
directive.

I just want reports to print into a separate window. How do I do that?
It's not clear at all to me

Craig
Kevin O. (Guest)
on 2006-03-07 22:07
(Received via mailing list)
<%= link_to "All Facilities", {:action =>
'fac_log_all'},{"target"=>"_new"} %>

This should work.

_Kevin
Berin L. (Guest)
on 2006-03-07 22:14
(Received via mailing list)
Craig W. wrote:
>
Try adding {} brackets around :action and then add , :target => "_new"

<%= link_to "All Facilities", {:action => 'fac_log_all'}, {:target =>
'_new'} %>
                              # ^^ link options ^^          ^^ html opts
^^
Craig W. (Guest)
on 2006-03-07 22:14
(Received via mailing list)
On Tue, 2006-03-07 at 20:04 +0000, Kevin O. wrote:
> <%= link_to "All Facilities", {:action =>
> 'fac_log_all'},{"target"=>"_new"} %>
>
----
indeed it does - thanks Kevin

Craig
Craig W. (Guest)
on 2006-03-07 22:41
(Received via mailing list)
On Tue, 2006-03-07 at 15:10 -0500, Berin L. wrote:
> >
> >
>
> Try adding {} brackets around :action and then add , :target => "_new"
>
> <%= link_to "All Facilities", {:action => 'fac_log_all'}, {:target => '_new'} %>
>                               # ^^ link options ^^          ^^ html opts ^^
----
perfect - and I actually understand it.

Similar doesn't work for 'start_form_tag'

<%= start_form_tag {:action => 'fac_log'}, {:target => "_new"} %>
  <%= options = [['Select a Facility', '']] +
      @facilities.collect {
      |fac| [fac.name, fac.id] }
      select 'report', 'facility_id', options %>
  <%= submit_tag ' Go ' %></td>
<%= end_form_tag %>

as any braces in <%= start_form_tag :action => 'fac_log' %>
seem to cause syntax errors

Is there a way to accomplish the same (new window) here?

Craig
Jonathan V. (Guest)
on 2006-03-08 02:47
You need brackets round the whole statement. I guess the interpreter
can't tell if you're passing a block or a hash, so...

form_tag({ :action => 'fac_log' }, { :target => '_new' })

-Jonny.

> Similar doesn't work for 'start_form_tag'
>
> <%= start_form_tag {:action => 'fac_log'}, {:target => "_new"} %>
>   <%= options = [['Select a Facility', '']] +
>       @facilities.collect {
>       |fac| [fac.name, fac.id] }
>       select 'report', 'facility_id', options %>
>   <%= submit_tag ' Go ' %></td>
> <%= end_form_tag %>
>
> as any braces in <%= start_form_tag :action => 'fac_log' %>
> seem to cause syntax errors
>
> Is there a way to accomplish the same (new window) here?
Craig W. (Guest)
on 2006-03-08 03:18
(Received via mailing list)
Thank you - that clearly worked.

This is not the first time I've said this on this list...
It is incredibly difficult to ascertain
when/if/which <=> brackets/braces/parens
are required in rails

Craig
This topic is locked and can not be replied to.