ruby - Porting form_for erb tag from Rails2 to Rails4 -


i'm trying port rails2 app rails4 app(!). not keeping separate branch port, instead delimiting rails4 specific api 'if' clause.

if rails::version::string < "4"     # rails2 specific api call else     # rails4 specific api call end 

so far, works controllers , models. however, i'm having issue erb rails2.

<% if rails::version::string < "4" %>     <% form_for(...) |f| %>     <% end %> <% else %>     <%= form_for(...) |f| %>     <% end %> <% end %> 

it fails since in rails2, erb evaluates else clause , fails render <%= form_for(...) |f| %> because in rails 2, object returned form_for has no .to_s method.

do guys know tips work around this?

try putting rails 4 code block. define rails4_stuff somewhere in helper:

# application_helper.rb  def rails4_stuff  yield if rails::version::string < "4" end 

and in erb:

<% rails4_stuff %>  <% form_for(...) |f| %>  <% end %> <% end %> 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -