Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

for 0.9.4 Undefined method content_columns for non activerecord subclassed models #143

Closed
kristopher opened this Issue · 7 comments

2 participants

@kristopher

When using formtastic with authlogic's UserSession class I am getting this error:


undefined method `content_columns' for UserSession:Class 

formtastic (0.9.4) rails/./lib/formtastic.rb:424:in `content_columns'
formtastic (0.9.4) rails/./lib/formtastic.rb:1125:in `field_set_and_list_wrapping'
formtastic (0.9.4) rails/./lib/formtastic.rb:272:in `inputs'

@grimen

Weird, the rescue don't trap that one... =S

self.model_name.constantize.content_columns.collect { |c| c.name.to_sym }.compact rescue []

...haven't tried it myself yet, but as u running 0.9.4...

@grimen

I can't reproduce this in a spec (did my own non-activerecord-dummie-class without any methods/attributes). Could you maybe?

@kristopher

It is erroring on line 424 which is not rescued. Try testing it again with a single attribute and pass an object to semantic_form_for


class Foo
  attr_accessor :attr
end

This works:


<% semantic_form_for(:foo, :url => '/' do |f| %>
  <%= f.inputs :attr %>
<% end %>

This errors:


<% semantic_form_for(Foo.new, :url => '/' do |f| %>
  <%= f.inputs :attr %>
<% end %>

Which is expected since the symbol fails the conditional check on line formtastic.rb:423 and is rescued on line formtastic.rb:426. But when passed an object it passes the conditional check and gets the undefined method error since it is not rescued on line formtastic.rb:424.

Hope that helps.

@grimen

Oh, peep the master version - this one is patched (actually more like refactored, but handles such errors with the line I dropped in the first reply) already for 0.9.5. Stay tuned.

@grimen

Closing, could not reproduce in master.

@kristopher

Cool man, thanks for looking at it.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.