Rails 3.1.3 I have a model, 'Script' like
class Script < ActiveRecord::Base belongs_to :video has_many :users validates :startp, :presence => true, :uniqueness => true, #HERE!!!! :numericality => { :only_integer => true, :less_than => 1000} validates :script, :presence => true end As seen, 'script' has a field 'startp' which is unique. So when users try to save a 'script' having the 'startp' which is identical with that of another 'script', the 'save' action fails. Correct me if I am wrong. Then, I would like to set up the action upon the failure as follows def create @script = Script.new(params[:script]) respond_to do |format| if @script.save format.json { render json: @script, status: :created, location: @script } else format.html { redirect_to @script } #HERE!!!! # format.json { render json: @script.errors, status: :unprocessable_entity } end end end hoping that it will redirect to 'script' page. But it doesnt. Could anyone point out where I am mistaken? Thanks in advance. soichi -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.