Ruby | Ruby on Rails Answers

Questions: 17

Answers by our Experts: 5

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

1)Define a ruby function named milestones.

2) Input parameter of the milestones method should be an array of 'running events taken by

a person' which is again an array.

Each running event taken by a person is an array which contains the following values

1st array element - date when he participated in the run,

2nd array element - time taken to complete the run,

3rd array element - distance of the run

example Input below

Array element description: [ date_of_run, finish_time_in_minutes, length_of_run_in_kms

]

john_runs = [

[ "29-5-2017", 15, 5],

[ "9-3-2017", 35, 10],

[ "29-3-2017", 13, 5],

]

3) Implement the logic in the method so that the output should be an array of fastest times for

distances 5, 10 and 15 kms in that order

output = [ fastest time for 5 kms, fastest time for 10 km, fastest time for 15 kms]

-> If no run is found in the distance, the output should be 0 for that

ex: for the input above example john_runs, only runs with 5 and 10 kms are performed

and no 15km run is performed, the output should be [13, 35, 0],explanation of the output array: 13 - fastest time for a 5 km run, performed by john , 35 -

fastest time for 10 km run performed by john, 0 - as no 15 km run is performed by john


a circular racetrack is composed of four sections: concrete, mud, asphalt, and sand. A car takes 30 seconds to cross the concrete section, 45 seconds to cross the mud section, n5 seconds to cross the asphalt section and 40 seconds to cross the sand. Write a program that takes a positive time in seconds as input and detemine where the car is. assume the car starts at the concrete section i
Tom, Dick and Harry go to a restaurant. Each of them has a certain amount of money. When their monies are pooled they discover they have S Rs. Next, they start going through the menu card to choose items they would like to order.

Your task is to help them find out how many different menu item combinations they can order. Since there can be many menu items with the same price, we are interested only in unique price combinations. Refer output specifications and examples to get a better understanding.

Constraints:
Pi > 0 ; where i = 1 to N and Pi denotes the price of the ith item
S > 0

i need a code .......
i have some doubts regarding OR EQUALS operator in ruby. how does ruby interpreter is implementing it.?
here is sample code
class C
def arr
@num ||= []
end
when we use or equals operator in this circumstance.first call to this method initializes it and added a element thats fine.how does it know when a second call to made to arr is done that array has one elemnt in it..
Can you help me with implementation CarrierWave in Rails
I had an error it says that NoMethodError in HomeworksController
and here my HomeworksController class:
class HomeworksController < ApplicationController
before_action :signed_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy

def create
@homework = current_user.homeworks.build(homework_params)
if @homework.save
flash[:success] = "Homework created!"
redirect_to root_url
else
@feed_items = []
render 'static_pages/home'
end
end
def new
@homework =Homework.new
end
def destroy
@homework.destroy
redirect_to root_url
end

def index
@homeworks=Homework.all
end

private

def homework_params
params.require(:homework).permit(:content, :attachment)
end
def correct_user
@homework = current_user.homeworks.find_by(id: params[:id])
redirect_to root_url if @homework.nil?
end
end
What type(s) of programming is needed to pull live pricing data from sites such as Amazon, Best Buy, Wal-Mart, Target, etc. and display those prices on your own site?
I have a project on ruby on rails.
1) I don't know if this project is in just ruby or it is in rails?
2) It seems that rack file is missing in that project I want to know that if it is true or false?
I tried PaperClipExample and it is working fine. I use s3 to store images. And i want to know how the images are displayed. To say exactly, i have

pic_file_name
pic_content_type
pic_file_size
pic_updated_at
in the user model. I do not have url of the pic in the model, then how can i able to get the images using

<%= image_tag @user.pic.url %>
I am new to rubyonrails and i would like to know from where to start learning. And what source would be more efficient to learn.
I having 2 tables client and group. Between them many to many HABTM relationship exist, which i already define using simple join table.
I having a problem with the Active record query interface . I have to write code for adding client to group and whenever i select any group display all the clients related to this group.
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS