开发者

In Rails 3, using Formtastic and Devise, generic routes producing errors when adding a new entry for a model

I have a very simple rails 3 program with 2 models: a user model for Devise and a writing model that captures a text field and the user's id.

My routes file is pretty basic:

devise_for :users
resources :users, :writings
root :to => "users#index"

And my form for writings, using Formtastic, is as well:

<% semantic_form_for(@writing, :html => {:method => :put}) do |f| %>
<%= f.input :main %>
<%= f.input :user_id, :collection => current_user, :as => :hidden %>
<%= f.buttons %>
<% end %>

When I try to create a new writing, the form looks开发者_运维技巧 great, but then when I hit submit, I get the following error:

No route matches "/writings"

I've run rake routes, and everything else seems to be working on, and I am using the default generate scaffold from rails, so the controller is the out of the box controller.

Any ideas on where I went astray?


Chris, try putting the declaration of the form like this

<% semantic_form_for @writing do |f| %>
<%= f.input :main %>
<%= f.input :user_id, :collection => current_user, :as => :hidden %>
<%= f.buttons %>
<% end %>

I've the idea that when you specify the :html parameter, you "override" some defaults in formtastic. Sorry, I'm not an expert on formtastic. I've used a bit and then decided to go for simple_form :).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜