Hi Scott, it is an interesting question. I was seeing in the source code
and I found that[0]. Basically, rails ask to  object if it is persisted or
not to create the id.
But this is a private method, then you should need to implement this logic
in a helper(?) or something.


[0]
https://github.com/rails/rails/blob/7a085dac2a2820856cbe6c2ca8c69779ac766a97/actionview/lib/action_view/helpers/form_helper.rb#L440

Matt's


On Mon, Aug 4, 2014 at 7:53 PM, Scott Ribe <scott_r...@elevated-dev.com>
wrote:

> I want to use a form's id in javascript that runs after the DOM is loaded,
> so what method would get the form's id for an object? In other words, there
> will be erb thus:
>
> <%= form_for(@obj) do |f| %>...<% end %>
>
> so what erb would give me the id which that form will get?
>
> I know I can just give the form a custom id as a workaround, but I really
> do not need to change the id, just know what it is. (I also can calculate
> it myself pretty easily, but I'd rather use the same method that RoR uses,
> for future-proofing.)
>
> This is all a very small issue, given the multiple easy workarounds. I'm
> just surprised that I could not find anything in the docs or forums. (RoR
> 3.2, BTW.)
>
> --
> Scott Ribe
> scott_r...@elevated-dev.com
> http://www.elevated-dev.com/
> (303) 722-0567 voice
>
>
>
>
> --
> 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/94762048-A38E-4D15-82BE-AC936BE37EDD%40elevated-dev.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALX-aHo2L1o6eRwGzbrYUy3Vg1w2nf_-sLXzXJ4BtUqGmX4ZPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to