Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## views/questionaires/new
- <%= error_messages_for :questionaire %>
- <% form_for(@questionaire) do |f| %>
- . . .
- <%= hidden_field_tag "time_started", Time.now %>
- <p>
- <%= f.submit "Create" %>
- </p>
- <% end %>
- ## controllers/questionaires_controller.rb
- def create
- @questionaire = current_user.build_questionaire(params[:questionaire])
- @questionaire.time_taken = Time.now - params[:time_started]
- respond_to do |format|
- if @questionaire.save
- flash[:notice] = 'Questionaire was successfully created.'
- format.html { redirect_to( :controller => "account", :action => "logout") }
- format.xml { render :xml => @questionaire, :status => :created, :location => @questionaire }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @questionaire.errors, :status => :unprocessable_entity }
- end
- end
- end
Add Comment
Please, Sign In to add comment