ruby on rails - undefined method `val' for #<Arel::Nodes::BindParam:0x007fa13ef32028> -


i new rails, , cannot figure out why error specified above when try create new application after login.

also, while looking @ solutions online, found there wrong foreign key. therefore, removed foreign key , added again using migration. however, schema.rb file shown below not show index, show student_id column.

questions :

  1. should creation of has_one , belongs_to association require 1 mention in routes.rb . ( read online require, why ? )
  2. how decide place belongs_to , has_one.
  3. how find out above error generated ?

model student ( created using devise )

class student < activerecord::base       devise :database_authenticatable, :registerable,          :recoverable, :rememberable, :trackable, :validatable        has_one :student_application  end 

studentapplication ( generate using scaffold)

class studentapplication < activerecord::base   belongs_to :student  end 

routes.rb

rails.application.routes.draw    resources :student_applications    devise_for :students    root to: "student_applications#index" end 

in controller student_application_controller.rb

def new   #@student_application = studentapplication.new   @student_application = current_student.build_student_application() end  def create   #@student_application = studentapplication.new(student_application_params)   #@new_student = student.find(params[:id])   @student_application = current_student.create_student_application(student_application_params)    respond_to |format|     if @student_application.save       format.html { redirect_to @student_application, notice: 'student application created.' }       format.json { render :show, status: :created, location: @student_application }     else       format.html { render :new }       format.json { render json: @student_application.errors, status: :unprocessable_entity }     end   end end  private def student_application_params   params.require(:student_application).permit(:student_id, :name, :phone, :email_id, :gpa) end 

schema.rb

  create_table "student_applications", force: :cascade |t|     t.string   "name"     t.string   "phone"     t.string   "email_id"     t.decimal  "gpa"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.integer  "student_id"   end    create_table "students", force: :cascade |t|     t.string   "email",                  default: "", null: false     t.string   "encrypted_password",     default: "", null: false     t.string   "reset_password_token"     t.datetime "reset_password_sent_at"     t.datetime "remember_created_at"     t.integer  "sign_in_count",          default: 0,  null: false     t.datetime "current_sign_in_at"     t.datetime "last_sign_in_at"     t.string   "current_sign_in_ip"     t.string   "last_sign_in_ip"     t.datetime "created_at"     t.datetime "updated_at"   end    add_index "students", ["email"], name: "index_students_on_email", unique: true   add_index "students", ["reset_password_token"], name: "index_students_on_reset_password_token", unique: true  end 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -