Thomaz Wanderbruck Schmidt

Joined

430 Experience
0 Lessons Completed
0 Questions Solved

Activity

I have one app where i have a scaffold with a register of peoples with photo, but for me search if the people have your datas registered in my system i need use face recognition for read face in web camera and read the photos of database and if search the people return your personal datas, how i can make this in rails ??? Im begginer with rails.
I need to implement this as soon as possible in my system, but I couldn't find anything on the internet very specific.

I have the views of devise in views/users, but I have one layout for all app in aplication.html.erb, but the devise i dont want to renderize with this layout, so I create a sessions controller and add this line code render "layouts/sessions" where i create a layout special for login with the form default of devise and I will customize. But when I add the authentication in application_controller:

before_action :authenticate_user!

I have the views of devise in views/users, but I have one layout for all app in aplication.html.erb, but the devise i dont want to renderize with this layout, so I create a sessions controller and add this line code render "layouts/sessions" where i create a layout special for login with the form default of devise and I will customize. But when I add the authentication in application_controller

before_action :authenticate_user!

the view return the follow error:

NoMethodError in #
Showing /home/thomazws/Documentos/rails/projetohroV2/app/views/layouts/sessions.html.erb where line #5 raised:

undefined method `name' for nil:NilClass
Extracted source (around line #5):
3
4
5
6
7
8

<%= render partial: "layouts/site/navbar"%>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>


<%= f.label :email %>

<%= f.email_field :email, autofocus: true, autocomplete: "email" %>

Rails.root: /home/thomazws/Documentos/rails/projetohroV2

Application Trace | Framework Trace | Full Trace
app/views/layouts/sessions.html.erb:5:in _app_views_layouts_sessions_html_erb__3586321389248541598_69851658500860'
app/controllers/sessions_controller.rb:2:in
class:SessionsController'
app/controllers/sessions_controller.rb:1:in `'

sessions_controller.rb

class SessionsController < Devise::SessionsController
render "layouts/sessions"
end

strange that when I take the devise form and <% = render partial: "layouts / site / navbar"%> and put the login again it loads together with the navbar that is in the partial, however if I update the page or I stop the server and turn it back on it returns the error.

Hello I have a scaffold with many inputs of datas of patients and now I need add a camp for take a photo with webcam and save a photo when the patients go save your datas profile save a photo along with your personal data. I use the MongoDB, the personal datas already save on mongodb atlas, i need just insert a camp for take a photo anda save on my Database.

Hello guys i have a project Rails 5 with database sqlite3 and a lot scaffolds, but now i need change the databse for MongoDB, but the MongoDB dont use the active record. How i change this or remove the active record for use mongoDB.

Hello guys i have a project Rails 5 with database sqlite3 and a lot scaffolds, but now i need change the databse for MongoDB, but the MongoDB dont use the active record. How i change this or remove the active record for use mongoDB.

Posted in Why this error ? how I fix this.

No, I doesn't know this.

Posted in Why this error ? how I fix this.

Yes here.

Model Patient:

class Patient < ApplicationRecord
    has_one :address

    accepts_nested_attributes_for :address
end

MIgration Patient:

class CreatePatients < ActiveRecord::Migration[5.2]
  def change
    create_table :patients do |t|
      t.string :name
      t.string :cpf
      t.string :rg
      t.string :phone
      t.string :birth
      t.string :mother

      t.timestamps
    end
  end
end

My Search Controller

class Backend::SearchController < ApplicationController

  def patients
    @patients = Patient.where(cpf: params[:q])
  end

end

Need more information ? Helpme pleaase hahahaha xD

Posted in Why this error ? how I fix this.

I have a form that has fields from two different tables, the Patients table and the Addresses table. Please make a search field to use only one patient (Patient) and return his data, up to the fields in the patient table and return the right data when adding a field to present a street in case of a street and it will be the following error:

NoMethodError in Backend::Search#patients

Showing /home/thomazws/Documentos/Rails/projetohroV2/app/views/backend/search/patients.html.erb where line #106 raised:

undefined method `street' for nil:NilClass

Extracted source (around line #106):

<p>
<strong>Rua:</strong>
<%= patient.address.street %>
</p>

I have a controller for Search with this code:

class Backend::SearchController < ApplicationController

  def patients
    @patients = Patient.where(cpf: params[:q])
  end

end

and my view:

  <% @patients.each do |patient| %>

                     <p>
                        <strong>Nome:</strong>
                        <%= patient.name %>
                    </p>


                      <p>
                        <strong>CPF:</strong>
                        <%= patient.cpf %>
                    </p>

                      <p>
                        <strong>RG:</strong>
                        <%= patient.rg %>
                    </p>

                      <p>
                        <strong>Telefone:</strong>
                        <%= patient.phone %>
                    </p>

                      <p>
                        <strong>Data de Nascimento:</strong>
                        <%= patient.birth %>
                    </p>

                      <p>
                        <strong>Nome da Mãe:</strong>
                        <%= patient.mother %>
                    </p>

                      <p>
                        <strong>Rua:</strong>
                        <%= patient.address.street %>
                    </p>
                <%end%>

I'm starting a project with rails 5 and the first thing I did was add the bootstrap to rails 5. I added the gem and imported it into application.scss. I generated a devise Admin and the bootstrap worked, but then I generated a controller with the following command Rails generate backend / dashboard index. On this backend dashboard my bootstrap is not working.

here my application.scss

/
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib / assets / stylesheets, or any plugin's
 * vendor / assets / stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS / SCSS
 * files in this directory. Styles in this file should be added after the last require_ * statement.
 * It is generally better to create a new file per style scope.
 *
 * /

// Custom bootstrap variables must be set or imported * before * bootstrap.
@import "bootstrap";

return this error now

unknown attribute 'street' for Patient.
Extracted source (around line #27

def create
@patient = Patient.new(patient_params)

respond_to do |format|
  if @patient.save

I am making a patient control system where I have the following tables that I need to list and present the data on the show.html.erb of patients.

I created a patient scaffold with the following data

  t.string :cpf
  t.string :name
  t.string :telephone
  t.string :rg
  t.date :birth
  t.string :mother

and a model address with the following data

t.string :street
t.integer :cep
t.string :city
t.string :state
t.string :neighborhood

the ratio is 1 to 1 (belongs to) my question is how do i do all this relation and how do i present the data from the addresses table in the patients show.html.erb.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.