Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## controller
- def create
- @state = State.new(params[:state])
- @state.tags.each {|tag| tag.destroy}
- @state.tags = params[:tags].map {|tag| Tag.find_by_id tag}
- respond_to do |format|
- if @state.save
- flash[:notice] = 'State was successfully created.'
- format.html { redirect_to(@state) }
- format.xml { render :xml => @state, :status => :created, :location => @state }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @state.errors, :status => :unprocessable_entity }
- end
- end
- end
- ## error
- ActiveRecord::StatementInvalid in StatesController#create
- Mysql::Error: Duplicate entry '1' for key 'PRIMARY': INSERT INTO states_tags (`updated_at`, `tag_id`, `id`, `state_id`, `created_at`) VALUES ('2009-06-12 10:59:01', 1, 1, 18, '2009-06-12 10:59:01')
- RAILS_ROOT: C:/rails/webstate
Add Comment
Please, Sign In to add comment