I have a very small application I ma building in rails. It is a simple weight tracker app. I have created a User
model which has a sign up page. Once the user logs in they are redirected to the user#show
view. Here is the user controller so far:
class UsersController < ApplicationController
before_filter :authenticate_user!
def show
@user = current_user
end
end
I have 2 other models one is a Weight
model and the other a Goal
model, I would like it so what when a user signs up they are presented with a screen asking them to type in the current weight and goal weight this information will then be store in the Weight
and Goal
models respectively along with the logged in users ID.
So far I have been able to add a form to the user show.html.erb
template :
<%= form_for @user do |f| %>
<%= f.fields_for :weight do |builder| %>
<fieldset>
<%= f.label :value, "Current weight" %><br />
<%= f.text_field :value %><br />
</fieldset>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Which renders the form correctly but when I then click on the submit button it simply goes to an error page saying Unknown action- The action 'update' could not be found for UsersController
. Im assuming iM doing something wrong as it should try and send to the create action.
Is there anyone out there who could help me back on the right path, Im very much a noob at rails.