Ruby on Rails - model validation -


i have problem simple model validation. entering materials without sku getting me error message:

nomethoderror in materials#create undefined method `empty?' nil:nilclass

enter image description here material.rb:

class material < activerecord::base   validates :sku, :presence => true end 

materials_controler.rb (create part only):

# post /materials   # post /materials.json   def create     @material = material.new(material_params)       respond_to |format|       if @material.save         format.html { redirect_to @material, notice: 'material created.' }         format.json { render :show, status: :created, location: @material }       else         format.html { render :new }         format.json { render json: @material.errors, status: :unprocessable_entity }       end     end   end 

define @units in create method


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -