Skip to content

Instantly share code, notes, and snippets.

@cmrichards
Created July 20, 2011 20:52
Show Gist options
  • Save cmrichards/1095907 to your computer and use it in GitHub Desktop.
Save cmrichards/1095907 to your computer and use it in GitHub Desktop.
=form_for :company_branch do |f|
.field
.label Company Type
.input=f.collection_select :company_type_id, CompanyType.not_expired, :id, :name
.field
.label Name
.input=f.text_field :name
.field
.label Address
.input=f.text_field :address
.field
.label Post Code
.input=f.text_field :postcode
.field
.label Phone
.input=f.text_field :phone
.field
.label Fax
.input=f.text_field :fax
.field
.label Email
.input=f.text_field :email
.field
.label Notes
.input=f.text_area :notes , :rows=>10, :cols=>50
.field
.label
.input=submit_tag "Save"
class CompanyBranchesController < ApplicationController
.....
def update
@company_branch = CompanyBranch.find params[:id]
if request.post?
if @company_branch.update_attributes params[:company_branch]
flash[:notice] = "Company updated."
redirect_to :action=>"show", :id=>@company_branch
end
end
end
error :
Couldn't find CompanyBranch without an ID
Parameters:
{"commit"=>"Save",
"authenticity_token"=>"5MFAaxP+LiZmCGlLEKEAi1AADaqtcq8Sy0NXYd/FL68=",
"utf8"=>"✓",
"company_branch"=>{"name"=>"Chris' House",
"address"=>"5 Lowerfold Drive,
Rochdale,
Lancashire",
"company_type_id"=>"1",
"postcode"=>"ol127ja",
"notes"=>"Some notes here.",
"phone"=>"09039093434",
"fax"=>"343434",
"email"=>"[email protected]"}}
Started POST "/company_branches/update" for 127.0.0.1 at Wed Jul 20 21:52:54 +0100 2011
Processing by CompanyBranchesController#update as HTML
Parameters: {"commit"=>"Save", "authenticity_token"=>"5MFAaxP+LiZmCGlLEKEAi1AADaqtcq8Sy0NXYd/FL68=", "utf8"=>"✓", "company_branch"=>{"name"=>"Chris' House", "address"=>"5 Lowerfold Drive, Rochdale, Lancashire", "company_type_id"=>"1", "postcode"=>"ol127ja", "notes"=>"Some notes here.", "phone"=>"09039093434", "fax"=>"343434", "email"=>"[email protected]"}}
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
Completed in 25ms
ActiveRecord::RecordNotFound (Couldn't find CompanyBranch without an ID):
app/controllers/company_branches_controller.rb:22:in `update'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment