bug: from_for in helpers fails when using both ERB and HAML

8 views
Skip to first unread message

grimen

unread,
Dec 13, 2009, 12:58:13 PM12/13/09
to Haml
My view helper looks like this:

def facebook_connect_form(for_resource, options = {})
logout_form = options.delete(:logout) || (options[:method]
== :delete)
options.reverse_merge!(
:id => (logout_form ? 'fb_connect_logout_form' :
'fb_connect_login_form'),
:style => 'display:none;'
)
resource = ::Devise::Mapping.find_by_path(request.path).to
rescue for_resource
url = logout_form ? destroy_session_path(resource) :
session_path(resource)
form_for(resource, :url => url, :html => options) { |f| }
end

but it turns out only the last line is the problemistic: form_for
(resource, :url => url, :html => options) { |f| }

When I install HAML in my Rails-project, and I call this method from
an ERB-view (consider I need ERB sometimes), then:

form_for(resource, :url => url, :html => options) { |f| } # => nil

When I call it from a HAML view it works. When I uninstall HAML from
the project, and call it from ERB, it works.

What's the problem here?


grimen



Nathan Weizenbaum

unread,
Dec 13, 2009, 3:42:57 PM12/13/09
to ha...@googlegroups.com
form_for isn't supposed to return anything, necessarily. It works purely via side-effect. I'm not sure I see the issue here.




--

You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.



grimen

unread,
Dec 13, 2009, 6:29:26 PM12/13/09
to Haml
If this would the case - "isn't supposed to return anything,
necessarily" (which I don't understand) - please explain then why it
works expected with ERB but not HAML? That is an issue for sure.


grimen
> > haml+uns...@googlegroups.com <haml%2Bunsu...@googlegroups.com>.

grimen

unread,
Dec 13, 2009, 6:33:44 PM12/13/09
to Haml
...if they both are used. Works if either on of ERB or HAML is chosen
- not both in same project. To me it seems like the HAML
initialization messing with Rails in a de-coupled way, which is okay
but should be mentioned in the README in such case I believe.

grimen

Nathan Weizenbaum

unread,
Dec 13, 2009, 9:28:41 PM12/13/09
to ha...@googlegroups.com
How are you calling form_for in ERB and Haml? How isn't it working, specifically?

To unsubscribe from this group, send email to haml+uns...@googlegroups.com.

grimen

unread,
Jan 7, 2010, 12:41:57 AM1/7/10
to Haml
The call is posted above, but here's a bit more readable one:

http://pastie.org/769862

See my initial post for answer on your second question. Can't really
make it more clear than that and it should be easy to reproduce as
well: Just call form_for(resource, :url => url, :html => options) { |
f| } from a helper with the conditions mentioned in the end of my
initial post and peep how the output differs (without HAML plugin and
with HAML plugin).


grimen

> > haml%2Bunsu...@googlegroups.com<haml%252Buns...@googlegroups.com>

Nathan Weizenbaum

unread,
Jan 7, 2010, 8:30:56 PM1/7/10
to haml
This still isn't clearly answering my question. What does your ERB template look like? What does your Haml template look like? What does the rendered HTML look like in each case, and how is this wrong?

To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages