0 Answer
  • 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Rails 6 JavaScripts

I'm trying to implement some JavaScript in my Rails 6 app, I have no idea if I'm going about it the right way but so far everything I've tried has been wrong.

I have a file javascripts/form_helpers/submit.js for now it just looks like this:

const submit_action() {   console.log("hello world"); } 

In javascripts/application.js I have

require("form_helpers");  # I've also tried require("form_helpers/submit.js") but I thought I could just include the directory which seems to be what Rails ships with for channels 

Then in the actual view I have a form_with tag:

  <%= submit_tag 'Submit', class: "button button-create button-log-radius", onclick: "submit_action()" %> 

I always get a reference error when I click the submit button that submit_action is not defined. Am I on the right track here? Am I way off base? I'm a little confused by this new javascript folder, am I using it right or should I be putting scripts like this into the assets directory?

BTW I've seen this question asked before on here and the answer had to do with appending window before your function name (here) but that feels hacky to me.

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]