Emrah Yıldırım


190 Experience
0 Lessons Completed
0 Questions Solved


I have a form area like the one below, and if you have an e-mail address, I want a value for that email address sent. But I'm getting an error that there's no value.

I want the value of the e-mail to be e-mailed.

undefined method `value' for nil:NilClass

Extracted source (around line #71):

 rad_check = params[:emailaddress]
 **data = RadCheck.find_by(emailaddress: params[:emailaddress]).value**
 RadCheckMailer.rad_check_forgot(rad_check, data).deliver


def forgot    
  rad_check = params[:emailaddress]
  data = RadCheck.find_by(emailaddress: params[:emailaddress]).value
  RadCheckMailer.rad_check_forgot(rad_check, data).deliver           


class RadCheckMailer < ApplicationMailer
    default :from => "[email protected]"

    def rad_check_forgot(emailaddress, data)
        @rad_check_data = data
        mail(:to => emailaddress, :subject => "Forgot")


<%= @rad_check_data %>



<%= form_tag 'forgot' do %>

      <div id="error" class="middle-box text-left loginscreen">
        <%# Error Messages display here! %>

      <div class="form-group">
        <%= text_field_tag  "emailaddress" %>

      <div class="form-group">              
        <%= submit_tag "submit"%>
    <% end %>
    <p class="m-t"> <small>Corperation &copy; 2019</small> </p>

RadCheck Table

class CreateRadChecks < ActiveRecord::Migration[5.2]
  def change
    create_table :rad_checks, force: :cascade do |t|

      t.string :value,        :limit => 253, default: "",   null: false      
      t.string :emailaddress


    add_index(:rad_checks, :emailaddress, {:name=>:emailaddress, :length=>{:emailaddress=>32}, :using=>"btree"})

Posted in Chart Size Convert

You did the best you could for me... I don't have to use Chartkick. Can you recommend another library or method other than Chartkick? Frankly, you've wasted enough time for me.

I'm using the Chartjs library

Posted in Chart Size Convert

First of all, the code you gave me worked. Thank you so much for that.
Number_to_human_size is doing the calculation, but does not add MB, GB, TB to the end.

You can see it in the picture below.


Posted in Chart Size Convert


I've looked at this link before. Actually, there's no mistake. The data from the Download table comes in the form of bytes, and I want to show this data in the form of megabyte, gigabyte and Terebyte.

<% @tasks.each do |task| %>
   <tr class="gradeX">
     <td><%= Time.at(task.intime).utc.strftime("%H:%M:%S") %></td>
      <td><%= number_to_human_size(task.downloads) %></td>
      <td><%= number_to_human_size(task.uploads) %></td>
 <% end %>

I managed to show it using Number_to_human_size on the index page with the code above.

However, when I want to display the same process with Chartkick gem file, the data appears as byte.

What's important is how do I add a method like Number_to_human_size to the following Chatkick code?

<%= line_chart Item.group_by_month(:created_at).sum(:download) %>

Posted in Chart Size Convert

Is there anyone who can help me with this?


Posted in Chart Size Convert


I have a table called Download, the data in this table comes in bytes.
I want to prepare a chart with Chartkick. However, with the following code, the data comes in bytes. I want it to come in the form of Mb or Gb.

<%= line_chart Item.group_by_month(:created_at).sum(:download) %>

Can this code be used with something like number_to_human_size?

Posted in How do I convert a SQL query to rails?


I'm new to ROR. The query I created below is functioning properly. I'm trying to prepare an interrogation. But I didn't succeed. The query is as follows;
@rad_check.tenant_id = SELECT groupname FROM radgrs INNER JOIN nas WHERE radgrs.tenant_id = nas.tenant_id AND nas.realipaddr = ""

How do I make a switch case for the following queries in another question? Returns NULL if the query fails.

Thank you for caring.

def realipaddr

  def create
    @rad_check = RadCheck.new(rad_check_params)
    **@rad_check.tenant_id = Na.find_by(realipaddr: realipaddr, active: :true).tenant_id**

    respond_to do |format|
      if @rad_check.save
        format.html { redirect_to @rad_check, notice: 'Rad check was successfully created.' }
        format.json { render :show, status: :created, location: @rad_check }
        format.html { render :new }
        format.json { render json: @rad_check.errors, status: :unprocessable_entity }
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.