Hello there,
I'm using rails 3.0.3 and thinking sphinx 2.0.1 and I'm having trouble
with STI and form_for when the plugin is enabled.

I have a nested resource, routed as:

resources :sections do
  resources :articles do
    member do
      get 'preview'
      get 'publish'
    end
  end
end

Article is the parent class for a number of different article classes
all using STI

To handle this in my new/edit actions I have the following form_for in
the view:

<%= form_for [@section, @article], :html => { :multipart =>
true, :class => "articleForm" } do |f| %>
<%= hidden_field_tag(:type, @article.type.underscore) %>

this in my article model:

# http://code.alexreisner.com/articles/single-table-inheritance-in-rails.html
def self.inherited(child)
  child.instance_eval do
    def model_name
      Article.model_name
    end
  end
  super
end

and this in my controller:
def create
  @article = params[:type].camelize.constantize.new(params[:article])
  ...
end

this enables my nested resource form to use the article_ syntax -
which is all working nicely until I install thinking sphinx!

Now I get:

NoMethodError in Articles#new
Showing /Users/dorian/Sites/conran/app/views/articles/_form.html.erb
where line #2 raised:
undefined method `section_full_articles_path'

where full_article is the name of my article subclass.

Is there any way anyone can think of to workaround this?

I've tried using the subclassed articles in form_for so that I get
form parameted in the form e.g. full_article[], but then this seems to
be breaking my controller and complicating things (even further...).

thanks

Dorian

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to