Re: [Rails-core] Feature Request: form associated element

2014-10-14 Thread Matt Jones

On Oct 13, 2014, at 10:34 PM, Khoa Nguyen  wrote:

> As far as I know, Rails doesn't generate form attribute for input control 
> tags because it's assumed that form content is captured and rendered within a 
> block.
> 
> # typical rails form usage
> <%= form_for(object) do |f| %>
>   <%= f.text_field :bam %>
> <% end %>
> # generates
> 
>   ...
>   
> 
> 
> 
> The assumption has a limitation that content must not contain another form 
> element. [w3 
> spec](http://www.w3.org/TR/2011/WD-html5-20110525/association-of-controls-and-forms.html#association-of-controls-and-forms)
>  defines a set of attributes on input tags to associate themselves to their 
> form.
> 
>  
> # decoupled control and its form
> 
> 
> # control input can be placed outside of form tag
> # but still be associated to its form
> 
> 
> 
> Will Rails support auto generation of form attribute on input controls, that 
> are outside of form tag? Is this feature on the roadmap?
> 
> Quick hacks are most welcomed :)

Auto-generation seems unlikely - the ID of every form on the page would have to 
be stashed someplace template-wide and then the right one would need to be 
picked. That’s not even counting how *forward* references would need to work 
(form elements that precede the form in the DOM).

Haven’t tried it, but does explicitly adding `form: ‘whatever_your_form_id_is’` 
to the `html_options` for an input tag do the right thing?

—Matt Jones




signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [Rails-core] Feature Request: form associated element

2014-10-14 Thread Nicolas Cavigneaux

Le 14 oct. 2014 à 14:29, Matt Jones  a écrit :

> Haven't tried it, but does explicitly adding `form: 
> 'whatever_your_form_id_is'` to the `html_options` for an input tag do the 
> right thing?

Yes it does work, you can pass any html attribute you want and it will be use 
as-is. But I think he's asking if he can use form_for variant of helpers 
outside of the form_for block.

So you can use *_tag helpers outside of a form_for and set 'form' attributes by 
hand but you'll also need to handle value attribute.
--
Nicolas Cavigneaux
http://www.bounga.org
http://www.cavigneaux.net

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


[Rails-core] rescue_from with block causes memory leak

2014-10-14 Thread Lazarus Lazaridis
I wrote the following post about how a rescue_from in a controller causes 
memory leak 
 
due to symbol creations.

http://arubystory.blogspot.com/2014/10/rails-32-rescue-from-memory-leak.html

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.