I have FamiliesController with these actions:
def edit
@family=Family.find(params[:id])
end
def update
@family=Family.find(params[:id])
@family.update_attributes(params[:family])
end
Family model: (Using Mongoid)
attr_accessible :location
field :location
edit.html.erb
<div class="container">
<%= form_for @family do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :location %><br />
<%= f.text_field :location %>
</p>
<%= f.submit "Submit" %>
</div>
rotues.rb
resources :families
But when I submit the form I get:
AbstractController::ActionNotFound at /families/5235513e1dba7f8605000004
The action '5235513e1dba7f8605000004' could not be found for FamiliesController
(5235513e1dba7f8605000004) is id of the person
What is wrong here?
EDIT
So I found out on SO and it looks like Rails does not support alphanumeric IDs Also the gem mentioned in the answers don't work in mongoid (they are only for ActiveRecord models). So how to sort out this issue for Mongoid?
Does that mean I cannot use the Rails update method to update my database records in Mongoid?
Rails does not support alphanumeric IDs by default, it expects an integer.
If you need to make the IDs alphanumeric, you need to make some changes. Please look at the following resources:
Altering the primary key in Rails to be a string
http://railscasts.com/episodes/63-model-name-in-url-revised
http://railscasts.com/episodes/314-pretty-urls-with-friendlyid
I moved the
to top of the routes.rb. And now it works fine.
Don't no why it is so.