I am trying to develop an application that allows users to submit
articles and add information about the references they used when
citing facts. I have the sources broken down into types, such as
books, periodicals, web-sites, etc as single table inheritance on the
sources table. Routes are nested so that :articles, :has_many
=> :sources When trying to edit a source, through the “edit” view, I
get “ActionController::MethodNotAllowed - only get, put, and delete
requests are allowed”. This should flow through the “update” action,
which is a put method, and when I used rake routes on the command line
it looks like it is routed correctly PUT /articles/:article_id/
sources/:id(.:format) {:controller => “sources”, :action =>
“update”}
My edit view contains the following code:
<% form_for :source, @source, :url => {:action => “update”} do |f| %>
…form fields…
<%= f.submit “Update” %>
<% end %>
My controller has the following code:
def edit
@source = @article.sources.find(params[:id])
end
def update
@source = @article.sources.find(params[:id])
if @source.update_attributes(params[:source])
flash[:notice]…
redirect_to article_path(@article) #@article is derived from
before filter
else
render :action => “edit”
end
end
Any suggestions?
Thanks for you help!!!
-Kevin