ruby on rails – Problema com “undefined method `image1′ for nil:NilClass”

Estou desenvolvendo um site de imobiliária em Ruby on Rails e acabei tendo problemas quando criei uma rota chamada realtors ( rails g controller realtor index), servindo para aglutinar todos os corretores cadastrados e dessa forma pegar os profiles que estão em agent_details.html.erb (pasta properties).
Nao sei porque está dando NilClass em tudo que tem @agent. O que devo colocar no controller do realtor pra nao dar erro? Já tentei de tudo.

No index do realtors declarei:

<%= render "properties/agent_details", properties: @accounts %>

Fui na tentativa e erro várias vezes pra ver se conseguia, porém o erro comum é undefined method `image1′ for nil:NilClass

agent_details.html.erb:

 <div class="row">
   <div class="col-12 pr-1 pl-1">
      <button class="btn btn-block btn-info text-uppercase mb-3" id="show-tel" data-telephone="<%= @agent.telephone %>"><i class="fas fa-phone mr-2"></i><span>Call</span></button>
     </div>
   </div>

<div class="row">
  <div class="col-md-6 pr-1 pl-1 pb-1">
    <%= link_to "Profile", profile_path(@agent.id), class: "btn btn-secondary btn-block text-uppercase" %>
    </div> 
      <div class="col-md-6 pl-1 pr-1">
        <button class="btn btn-block btn-success text-uppercase" data-toggle="modal" data-target="#contact-modal">Email</button>
      </div> 
    </div>
 </div>

O que devo declarar no realtors_controller.rb para que não de erro?
Sei que no ActiveRecord as classes declaradas para agent, como image1, telephone e full_name pertencem ao Account:

add_image1_to_account.rb

class AddImage1ToAccount < ActiveRecord::Migration(6.0)
  def change
    
    add_column :accounts, :company, :string
    add_column :accounts, :image1, :string
  end
 
end

add_telephone_to_account.rb

class AddTelephoneToAccounts < ActiveRecord::Migration(6.0)
  def change
    add_column :accounts, :telephone, :string
  end
end

account.rb

class Account < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable



  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable, :trackable, :confirmable
   
         has_attached_file :image1, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/img"
         validates_attachment_content_type :image1, content_type: /Aimage/.*z/       
   
         has_attached_file :coverimg, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/img"
         validates_attachment_content_type :coverimg, content_type: /Aimage/.*z/ 

  has_many :properties
 
  def full_name
    "#{first_name} #{last_name}"
  end
 
end

Espero que tenham compreendido minha duvida e agradeço pela ajuda!

nt.number theory – Can the Selberg-Delange method be extended to analyzing $sum_{n

The famous Selberg-Delange method takes sequences $a_n$ whose associated DGF $F(s)=sum_{n=1}^{infty}frac{a_n}{n^s}$ has a representation

$$F(s)=G(s;z)zeta^z(s)$$

where $G(s;z)$ is “nice enough” and turns this into exact asymptotics (in terms of polynomials) on $sum_{n<x}a_n$. Can the main result of this method be adapted to obtain assymptotics on $sum_{n<x}frac{a_n}{n}$ instead?

My overall goal would be to approximate quantities similar to

$$sum_{substack{n<x\omega(n)=k}}frac{1}{n}$$

in much the same way as Tenenbaum approximates the quantity $sum_{substack{n<x \ omega(n)=k}}1$. Is this reasonable to expect? Can these theorems be changed to fit my needs?

Does overriding this method violate LSP?

If a base class Logger has a method reportError that takes an Error object and formats it as a string.

If a subclass implements that method but outputs the string in a different format, yet a string format nonetheless, does it violate the LSP?

I know that adding methods to the subclass doesn’t violate the LSP, it just needs to be able to be tested where it’s base class is used.

[VIP/PREMIUM] CASHMINING METHOD – EARN UP TO 500$/DAY WITH THIS METHOD. (WORKING) | Proxies-free

Hey there,
You can remember me from the News Website+AdSense+DigitalOceanVPS Method that i offered for free.

I got into a new method, it’s about a CashMining System based on surfing websites that brings you money from AD Networks and Membership Package Sellings, and i will give this tip for FREE for you, hard working users.

We present you: CashMining Method!

Note that this isn’t just a money making method, this is a business! Yes you will build yourself a business!

If you are interested in this method just reply to this thread and give some REP, it’s FREE.

FAQ:

Q: Do i need a start budget to do this?
A: Yes, you will need a start budget, it’s all written on the PDF with all the info you need.

Q: I will get guaranteed earnings?
A: Yes, we assure you that if you complete all the steps from the 1st one to the last one you will earn money!

Q: Do i have to surf websites?
A: No, yoyu don’t, you will be the website’s owner and you will get users that will surf websites on your platform.

Q: How do i get the method?
A: Go to https://mnshop.org/product/free-cashmining-method/ and Add to Cart the method, DON’T WORRY, IT’S FREE, they uploaded as a product for one reason: You register, Add to cart, Get a permanent download link and you won’t loose the file, you can download it how much times you want, whenever you want!
Best regards,

 

[FREE VIP METHOD] CashMining Method – Earn up to 500$/day with this method. (WORKING) | Proxies-free

Hey there,
You can remember me from the News Website+AdSense+DigitalOceanVPS Method that i offered for free.

I got into a new method, it’s about a CashMining System based on surfing websites that brings you money from AD Networks and Membership Package Sellings, and i will give this tip for FREE for you, hard working users.

We present you: CashMining Method!
[​IMG]

Note that this isn’t just a money making method, this is a business! Yes you will build yourself a business!

If you are interested in this method just reply to this thread and give some REP, it’s FREE.

FAQ:

Q: Do i need a start budget to do this?
A: Yes, you will need a start budget, it’s all written on the PDF with all the info you need.

Q: I will get guaranteed earnings?
A: Yes, we assure you that if you complete all the steps from the 1st one to the last one you will earn money!

Q: Do i have to surf websites?
A: No, yoyu don’t, you will be the website’s owner and you will get users that will surf websites on your platform.

Q: How do i get the method?

Hidden Content:

You must reply before you can see the hidden data contained here.

Best regards,
Dan @ MNShop.org.

 

magento2.3.4 – Magento 2 – Disable Payment Method for Certain Customer Groups by using Observer

Source : https://www.magedelight.com/resources/how-to-disable-payment-method-for-certain-customer-groups-in-magento-2/ Stright opposite i just enable certain customer group,

app/code/Gta/EnablePaymentMethod/registration.php

<?php
MagentoFrameworkComponentComponentRegistrar::register(
    MagentoFrameworkComponentComponentRegistrar::MODULE,
    'Gta_EnablePaymentMethod',
    __DIR__
);

app/code/Gta/EnablePaymentMethod/etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="payment_method_is_active">
        <observer name="enable_payment_customer_group" instance="GtaEnablePaymentMethodObserverPaymentMethodEnable" />
    </event>
</config>

app/code/Gta/EnablePaymentMethod/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Gta_EnablePaymentMethod" setup_version="1.0.0" schema_version="1.0.0"/>
</config>

app/code/Gta/EnablePaymentMethod/Observer/PaymentMethodEnable.php

<?php
namespace GtaEnablePaymentMethodObserver;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class PaymentMethodEnable implements ObserverInterface {
    protected $_customerSession;
    public function __construct(
       MagentoCustomerModelSession $customerSession
    ) {
       $this->_customerSession = $customerSession;
    }
    public function execute(Observer $observer) {
       $payment_method_code = $observer->getEvent()->getMethodInstance()->getCode();
       if ($payment_method_code == 'paypal_express') {
           $result = $observer->getEvent()->getResult();
           if ($this->_customerSession->isLoggedIn()) {
               $customerGroupId = $this->_customerSession->getCustomer()->getGroupId();
               if ($customerGroupId == 9) {
                   $result->setData('is_available', true);
               }
           }
       }
    }
}

Anything else i forget to do?

unity – Is using events a good way to have the option to return out of a method or alter its normal execution?

Let’s say I have a script that calls a method frequently, and when doing so wants to allow other objects to know about it and potentially alter what happens in that method. This is fairly simple to do using C# events:

public class PassByReference 
{
    public bool foo;

    public PassByReference(bool foo)
    {
        this.foo = foo;
    }
}

public class Example : MonoBehaviour
{
    public event Action<PassByReference> OnSomethingHappened;

    private void DoSomething()
    {
        var returnOut = false;

        // Do some stuff

        var passByReference = new PassByReference(returnOut);
        OnSomethingHappened?.Invoke(passByReference); // Some other object can read and alter this

        if (passByReference.foo)
            return;

       // Do some more stuff
    }
}

Is this a good way to do things if one anticipates that, based on a combination of the information given by the event, and their own properties, other objects may want to stop the second half of the Example method from running (or maybe alter what happens)? I guess what I’m trying to do is prevent the Example class from having to store references to many other classes that will interact with it only occasionally, and clog up the method with many if statements. My main concern, though, is that frequently creating new classes to pass data via reference in the event(s) can lead to performance issues, especially if many objects in my game are using the Example script.

8 – What is the acceptable method for importing addresses via feeds?

I have a list of businesses that I need to import and naturally they all have addresses. However the field address on my content type is not targetable during mapping, but all the other fields are. I did some google searching and because address field is not a core feature and part of a contrib module, I cannot do this?

Is there a way around this? I can’t manually input all these businesses, it would take far too long! What is the appropriate way to tackle this?

magento2 – Magento 2 – How does getShippingMethodTitle know the method title in module-tax/view/frontend/web/js/view/checkout/cart/totals/shipping.js

Now I understand. The script vendor/magento/module-tax/view/frontend/web/js/view/checkout/cart/totals/shipping.js (Script A) is not the script where the method is defined.

The template is using the script under the similar path as the template.
The template path is:

view/frontend/web/template/checkout/summary/shipping.html

so the script path is at

view/frontend/js/view/checkout/summary/shipping.js (Script B)

In view/frontend/js/view/checkout/summary/shipping.js (Script B) there is

Magento_Checkout/js/view/summary/shipping defined as Component.

define((
    'jquery',
    'Magento_Checkout/js/view/summary/shipping',    // <-- it uses this a Component
    'Magento_Checkout/js/model/quote'
), function ($, Component, quote) {
    'use strict';

    var displayMode = window.checkoutConfig.reviewShippingDisplayMode;

    return Component.extend({
    ...

If we look at vendor/magento/module-checkout/view/frontend/web/js/view/summary/shipping.js then we will see, that the method is defined there:

/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define((
    'jquery',
    'Magento_Checkout/js/view/summary/abstract-total',
    'Magento_Checkout/js/model/quote',
    'Magento_SalesRule/js/view/summary/discount'
), function ($, Component, quote, discountView) {
    'use strict';

    return Component.extend({
        defaults: {
            template: 'Magento_Checkout/summary/shipping'
        },
        quoteIsVirtual: quote.isVirtual(),
        totals: quote.getTotals(),

        /**
         * @return {*}
         */
        getShippingMethodTitle: function () {
            var shippingMethod = '',
                shippingMethodTitle = '';

            if (!this.isCalculated()) {
                return '';
            }
            shippingMethod = quote.shippingMethod();

            if (typeof shippingMethod('method_title') !== 'undefined') {
                shippingMethodTitle = ' - ' + shippingMethod('method_title');
            }

            return shippingMethod ?
                shippingMethod('carrier_title') + shippingMethodTitle :
                shippingMethod('carrier_title');
        },