Thanks for sharing. I'm trying to use this code but getting a "Symbol as array index" error because response.instance_variable_get(:@session) is returning an array, not a hash. Any tips? I would be anxious to see more of your login solution if you don't mind, since I'm trying to solve the same problem.
Thanks, Carl On Feb 21, 8:52 am, Cleverlemming <[email protected]> wrote: > I created a custom tag for my MailChimp list sign-ups using the > Hominid gem. I ran into a bit of a challenge with the fact that there > doesn't seem to be a way to use form helpers inside a custom tag as > custom tags use %{ to escape html, which means that a rails <% tag is > misinterpreted as part of another escape clause. I found one post that > claimed form helpers could be used in custom tags but there was no > example of usage. > > It's easy to use html within a custom tag, but a straight html form > will raise a InvalidAuthenticityToken error as the authenticity token > is not explicitly supplied. I used the following hack to create a > submittable form within a custom tag: > > <input name="authenticity_token" type="hidden" > value="#{response.instance_variable_get(:@session)[:_csrf_token]}" /> > > This creates the same output as when a form helper tag is used and the > form submits. I just have to type <r:subscribe /> to get my form to > appear on any page. > > Hope this is useful and it saves someone some time.
