Emrah Yıldırım

Joined

190 Experience
0 Lessons Completed
0 Questions Solved

Activity

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

rad_checks_controller.rb

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

rad_check_mailer.rb

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

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

rad_check_forgot.text.erb

<%= @rad_check_data %>

Tanks!

forgot.html.erb

<%= form_tag 'forgot' do %>

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



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



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

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


      t.timestamps

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

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.

https://cdn1.imggmi.com/uploads/2018/12/11/e7693f4727397b2957f9d5e5a33c02d8-full.jpg

Posted in Chart Size Convert

Hey

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>
   </tr>
 <% 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?

Respects

Posted in Chart Size Convert

Hi

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?

Hi,

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 = "192.168.22.175"

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
    request.remote_addr
  end

  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 }
      else
        format.html { render :new }
        format.json { render json: @rad_check.errors, status: :unprocessable_entity }
      end
    end
  end
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.