Webforms – Send a form in Rail with Unity to an HTTP server

I am trying to use UnityWebRequest to send a form to a Ruby on Rails server. However, the error "HTTP / 1.1 404 Not Found" will still be displayed.

My code is here:

public void Update_GI_Score () {StartCoroutine (Update_GI_Score_FORM ()); }

    IEnumerator Update_GI_Score_FORM ()
{
WWWForm form = new WWWForm ();
form.AddField ("myField", "myData");
Game Game = Singleton.GameInstance;
foreach (result s in game.scores)
{
form.AddField ("name", s.Name);
form.AddField ("value", s.rate.ToString ());
}
var url = RequestController.Instance.baseURL + "atualiza_score";
UnityWebRequest www = UnityWebRequest.Post (URL, Form);
Yield Return www.SendWebRequest ();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log (www.error);
}
otherwise
{
Debug.Log ("Form upload completed!");
}
}

In the rail routes I have:

Post & nbsp; atualiza_score & # 39 ;, Controller: & nbsp; integracao_games & nbsp ;, Action :: atualiza_score

So how can I get the form correct? I have to save the field in a database

Many Thanks.

Migrations in lib / Tasks / Migration – Ruby on rail

In my Ruby on Raille project that I am working on, I have noticed that they are migrating along the route lib / Tasks / Migration I do not know exactly how that worked and why it's done, but I have to use the same format and generate migrations that way.
I have a few questions:

1.- Because migrations are created on this route and not in db / migrate? (I have not found any information)

2.- How can I generate a migration on this route?

Ruby on rail – If a valid certificate file (PEM file) exists, upload the file

I just want to upload a certificate file when the credential_type is Linux, If it's windows, I do not want to upload the certificate.

Class Proof of Entitlement < ApplicationRecord
  enum credential_type: { windows: 1, linux: 2 }

  validates :user_name,       presence: { message: "User name can't be empty" }
  validates :credential_type, presence: true
  validate  :must_be_pem,     if: -> {Linux? && cert_file_path.present? }

def must_be_pem
cert_error_msg = & # 39; certificate is not valid & # 39;
fm = FileMagic.new (FileMagic :: MAGIC_MIME)
if fm.file (cert_file_path) = ~ / ^ text  // # text / plain
first_line = File.open (Appendix) {| f | f.readline}
if first_line.include? & # 39; ----- BEGIN RSA PRIVATE KEY ----- & # 39;
upload_certificate
otherwise
errors.add (: cert_file_path, cert_error_msg)
The End
otherwise
errors.add (: cert_file_path, cert_error_msg)
The End
The End

def upload_certificate
upload_dir = Rails.root.join (& # 39; private & # 39 ;, & # 39; certificate & # 39 ;, cert_file_path.original_filename)
File.open (cert_file_path, & # 39; w & # 39;) {| f | f.write (attachment.read)}
The End
The End

Do I need to get some code out of the model and use controller like certificate upload thing or should I use it? .valid? in the controller before saving. Here is my controller code:

create def
@credential = credential.new (credential_params)
Answer_on | format |
if @ credential.save
format.html {redirect_to credentials_url, Note: & # 39; Credential was successfully assigned. & # 39; }
format.js
format.json {render: show, status :: created, location: @credential}
otherwise
format.html {render: new}
format.js
format.json {render json: @ credential.errors, status :: unprocessable_entity}
The End
The End
The End

Update the values ​​of a table stuck in an array on Ruby on the rail

My problem is that I want to capture some data with a barcode gun. It works by reading the code and entering it automatically. In an input text I can enter several numbers that are read with the barcode gun. If you have an amount of X, you can transfer this collection of numbers with those numbers in that row to change a status field that I have from warehouse to transporter.

Many Thanks

Use ruby ​​on rails 5.2

Macro – What is a Focusing Rail?

The Focusing Rail is a type of camera mount that allows you to move the camera back and forth on a very small scale.


(Picture from article at Earthbound Light)

The reason for their use is that you have such a shallow depth of field in macro photography that it is easier to focus the lens at the given distance and then move the camera so that the desired parts are in focus, rather than the other Direction Always use the maximum magnification if you need to.

ruby on rail – Problem displaying all Json related objects in a model by their ID in RoR

I'm something new in rails and I have a show method that needs to depict Json objects from three models linked by their ID.

The models are the following:

Class Company <ApplicationRecord
has_many: areas
The End


Class Area <ApplicationRecord
belongs_to: company
has_many: area_contacts
The End

Class AreaContact <ApplicationRecord
belongs_to: area
The End

If the company has a company_id and is linked to the model space by this field, and area_contact is linked to the model space by the area_id field.

My show method in the companies_controller.rb file is defined as follows:

show def
@gebiete = @ unternehmen.gebiete

@ area_contacts = AreaContact.includes (: area) .find_by_area_id (@ areas.ids)

render json: {company: @company,
Areas: @ areas,
area_contacts: @ area_contacts
}
The End

The problem is that it only brings up the first area_contact, no matter how many are related to the area_id that the query is brought to when I call the company. That is, if I consult the company id = 1, I bring all areas with company_id = 1, and should in turn bring all the area_contact related to the area_id that brought the request through company_id = 1, but only the first.

I think the problem is defined in this part of my code:

@ area_contacts = AreaContact.includes (: area) .find_by_area_id (@ areas.ids)

I appreciate any help or comment.

Where do the UK National Rail trains have the rules and regulations for the timetable?

For example, can a train travel earlier than the departure time? If so, how much sooner?

I have looked at travel conditions that set minimum rights, but apart from the mention of "National Rail Timetable", the rail timetable for passenger trains available at www.nationalrail.co can be found in the UK.

Ruby on rail – child object can not delete parent object in before_destroy callback

I'm building a Calendar Rails app.
It has events that can contain one or more recurring events.
For example, "Runs 100 times every Monday."

If a user deletes all recurring events, I want the main event to be deleted as well.

1 class RecurringEvent <ApplicationRecord
27 belongs_to: event
35 before_destroy: delete_main_event_if_last_current

118 def delete_main_event_if_last_current
119 sets "# {event.recurring_events.size} left"
120 event.destroy if event.recurring_events.empty?
121 end

My test

            87 it "Delete main event when the last recurring event is deleted", focus: true do
88 event_id = @ event.id
89 @ event.recurring_events.each {| re | re.destroy! }
90 (Event.where (id: event_id) .count) .to eq 0
91 end

This results in this issue, but the main event is not clear.

Recurring event
Recurring events
5 left
5 left
5 left
5 left
5 left

Any idea why I do not delete the recurring events?

With byebug:

[117, 126]    in /app/app/models/recurring_event.rb
117
118: def delete_main_event_if_last_current
119: "# {event.recurring_events.size} remains left"
120: event.destroy if event.recurring_events.empty?
121: byebug
=> 122: end
123:
124: def day_as_changed
125: update_columns (
126: text_changed: (Saved_change_to_description? || Saved_change_to_title?),
(byebug) event.recurring_events.size
5
(byebug) event.recurring_events.first.destroy
zero
(byebug) event.recurring_events.size
5