Ruby

Ruby is an open-source dynamic object-oriented interpreted language that supports multiple programming frameworks including functional, object oriented and imperative. It also has a dynamic type system and automatic memory management. Ruby focuses on simplicity and productivity. Ruby's market share spiked due to Ruby on Rails, a model-view-controller (MVC) framework for building web applications.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a ruby on rails project and I am new to this framework. I  know we can download library/packages/gems to use in our projects. is there a gem that is suitable to make api calls to a third party rest based api?
0
We have an existing Redmine Tagging plugin that works in the 3.x branch of Redmine that we have in Production.
Unfortunately, the plugin is no longer in development and doesn't work in Version 4.x of Redmine, which is holding us back fro upgrading.
The original plugin is at https://github.com/Restream/redmine_tagging.
There are a couple of forks of the plugin that have been made, but the one that works only tags issues, not Wiki pages, wheras the original did both.
The other fork, at https://github.com/windviki/redmine_tagging, should work in 4.x.  It does work with Issues, but throws an error when trying to save a Wiki page:

"NoMethodError (undefined method `tags_to_update=' for nil:NilClass):

plugins/redmine_tagging/lib/tagging_plugin/tagging_patches.rb:19:in `update'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'"

A few people are experiencing the error, and the fork's developer has suggested adding some code to one fo the files, but this prevents the Wiki page from Saving at all (the comments are all ont he original Issue f the original plugin at https://github.com/Restream/redmine_tagging/issues/87).

I do not have much experience with Ruby and Rails (I've started learning but still wrapping my head around the basics of Ruby).

Is there anyone who could help with this error and advise on how to fix it?
0
I'm setting up Mac for ruby and rails development. here are the steps I took

installed RVM
installed Ruby                (version 2.6.5)
created gemset
rvm use ruby-2.6.5@gemset

gem install rails                 (version 6.0.2)

rails new todoApp

gem install bundler

bundle install

rails server - i ran into issue with starting a server.

I'm not sure if I did the things in order, but wanted to know how should i set up the ruby project.

first -> install ruby or set the version of ruby desired using rvm

then create gemset

then install rails, bundler

then run rails server.

are these the normal steps to take ?
0
I'm on a MacOs mojave which comes with a ruby version 2.3.7. I tried to install rails with gem install rails command, but got an error below : -

ERROR : you don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. I'm guessing as this version of Ruby comes with the MAC OS , it is not letting me change/update it.

How do I install a newer version of Ruby. Also, I have installed RVM (Ruby version manager )  and Homebrew as well, in my system.
0
I have been learning asp.net core. based on the tutorials, what it means that application will be hosted/served by kesterl server.

I have come across same idea reading about python, ruby on rails or  vue js, that the framework will spin up a web server. what does that mean? what actually happens in the background.

I apologize if the question is little vague, but I want to know what does the framework exactly do  in above situations compared to hosting an application in IIS?
0
I have a Windows 10 workstation that will not wakeup with a magic packet. Workstation remains offline.
This is a LAN only request at the layer 2 level. WOL is enabled in BIOS, and WOL is enabled within the OS for the adapter.
Local LAN is all I care about. There is however a Netgear Powerline 1200 provides connectivity.
Windows defender firewall is off but Webroot secureanywhere is installed.
Any suggestions? Thanks
0
Hello,
Any suggestions for an open-source Education ERP system under MIT or Apache license?
0
Have a Ruby script the ssh into multiple servers. I am trying to modify it so that it would first attempt  to use password and then 2nd attempt use a key.
Have script do each by there self however I need to have one script that will try to use password first then key.

Below is my script:
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'

USER = 'USER'
PASS = 'password'
KEY = "~/.ssh/id_rsa"
hosts = ['host1',  'host2',] 

hosts.each do |host|
  Net::SSH.start(host, USER, :password => PASS, :keys => KEY,
                   :auth_methods => ["password", "keys"], :port => 22,
                   :timeout => 5,
                   :non_interactive => true ) do |ssh|
     result = ssh.exec!('hostname')
     puts result
     result = ssh.exec!('hostname -i')
     puts result
     result = ssh.exec!("echo \'*** ****\'")
     puts result
     puts result
   end
end

Open in new window

0
StackOverflow refugee here. Apparently – according to the "help" I received there, I'm hosed. This is the question I asked initially:

Trying to install Jekyll, I get a warning that I need Ruby 2.1. I am running 2.0.0.

I run:

 brew upgrade ruby

Open in new window


Evidently, this was my first grievous error. Terminal goes through the process for a bit, then throws this error:

Error: The following directories are not writable by your user:
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions

Open in new window


So I run (as prompted):

chmod u+w /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions

Open in new window


then again run:

brew upgrade ruby

Open in new window


New error:

Error: Permission denied @ unlink_internal - /usr/local/lib/ruby/2.0.0

Open in new window


So I run (suggested by an SO post):

sudo chown -R $(whoami) /usr/local/lib/ruby/2.0.0

Open in new window


Then run:

brew upgrade ruby

Open in new window


and get:

Error: ruby 2.6.3 already installed

Open in new window


Okay... so I run:

ruby -v

Open in new window


and get:

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]

Open in new window


So Ruby 2.6.3 is installed, but I'm still running 2.0.0. So I run:

which -a ruby

Open in new window


and get:

/Users/me/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
/Users/me/.rvm/bin/ruby
/usr/bin/ruby

Open in new window


No sign of 2.6.3.

I'm out of my element here. Can anyone help me out?

End of post. Here are the comments I got (no answers, just SO users smelling noob blood in the water):

Not sure how you're going to dig yourself out of the hole you're in now, but never use brew to install Ruby. Always use a Ruby manager like RVM, and only a Ruby manager like RVM. Should be as simple as rvm install 2.1.10, then rvm use 2.1.10, then ruby -v.

I asked what hole?

The hole of having changed permissions across your filesystem & installed Ruby via brew. If you can get everything undone and switch to RVM exclusively you should be fine.
0
Hi : I am really proud of myself having written a ruby archive system that identifies recently amended files and copies them from x to y.
Trialling it on a linux PC works really well.
Accessing a Windows shared drive is pants.
I attach the code - and I suppose in this context the program does not matter - but the definition 'lister' identifies a local linux folder. Backup works
Replacing the lister reference (and its associated references blister, filer, and diler...yeah I am a crap programmer) with nister (and associated etc) does NOT work.
Does anybody know how to programmatically identify a remote samba shared folder on a windows server such that I can use it in the code as described? I copied the 'nister' reference directly from dolphin...am I doing something wrong?
ruby-archiver.txt
0
I am trying to use this code on the collections.liquid page of my website but for some reason it's not working:

{% for product in collection.products %}
  {% if product.tags contains 'outlet' %}{% continue %}{% endif %}
  <!-- your product grid item -->
{% endfor %}

Open in new window


I have added the "outlet" tag to the product that I do not want to appear but for some reason, it's still showing the product on the collections page?
0
why are those three commands different?

In ruby, we use puts, p, and print to print a line to screen to ask a question. Would someone please explain it to me the difference in the following situation?

if we do the following:
print "Input your string."
str = gets.chomp

or the following:
p "input your string."
str = gets.chomp

the screen will have the question printed out; then we can input a string.

However, if we do the following in the script:

puts "input your string."
str = gets.chomp

When we run it, the screen will not show the question. But, after we type something and hit a return, the question will pop out after we hit a return.

why does ruby work in that way?

thanks,
RDB
0
Hi. I have knocked out a Ruby On Rails website that lists HR documents; the plan being for a user to click on a button next to the document in the list and open the pdf with the HR policy.
Rails being Rails I have the list with 'Show' and 'Edit' buttons...but need a 'Display pdf' button, too. The pdfs are on the server, each named with the number of the primary key in the table (thus pdf /usr/var/www/html/docs/123456.pdf refers in the table to  id 123456). Does anybody know how to set up the code in the controller and view (index.html.erb) that can facilitate this, please?
0
i have a json file, which contains KV pairs like below.

{
"app1_ds1_ds_jndi": "value1",
"app1_ds1_ds_url": "value2",
"app1_ds1_ds_useri": "value3",
"app1_ds1_ds_pwd": "value4",


"app1_ds2_ds_jndi": "value5",
"app1_ds2_ds_url": "value6",
"app1_ds2_ds_user": "value7",
"app1_ds2_ds_pwd": "value8",


"app2_ds1_ds_jndi": "value9",
"app2_ds1_ds_url": "value10",
"app2_ds1_ds_user": "value11",
"app2_ds1_ds_pwd": "value12",

}


I want to parse the above file to grep for all app1 datasources, ignoring other apps like app2, app3 ..etc., and construct an array of hashes in ruby like below.




[{jndiname: "value1",  url_name:"value2" user_name: "value3", Password:"value4"},
{jndiname: "value5",  url_name:"value6" user_name: "value7", Password:"value8"}
]
0
How to connect on database phpmyadmin in ruby on rails? I already do rake db:migrate but it doesn't connect on my phpmyadmin. How do i do that?
0
Hello,
Im trying to translate this code from https://securionpay.com/docs/api#checkout-request-sign.
EXAMPLE SIGNING


export checkout_request='{"charge":{"amount":499,"currency":"EUR"}}'
export signature=`echo -n "$checkout_request" | openssl dgst -sha256 -hmac 'pr_test_tXHm9qV9qV9bjIRHcQr9PLPa' | sed 's/^.* //'`
echo -n "$signature|$checkout_request" | base64
        

EXAMPLE SIGNED CHECKOUT REQUEST


Y2Y5Y2UyZDgzMzFjNTMxZjgzODlhNjE2YTE4Zjk1NzhjMTM0Yjc4NGRhYjVjYjdlNGI1OTY0ZTc3OTBmMTczY3x7ImNoYXJnZSI6eyJhbW91bnQiOjQ5OSwiY3VycmVuY3kiOiJFVVIifX0=
				

Open in new window


to Ruby on Rails

I ended with

       
 checkout_request='{"charge":{"amount":5,"currency":"EUR","capture":true}}'
 secret_key = 'sk_test'
 @signature = Base64.urlsafe_encode64(OpenSSL::HMAC.hexdigest('sha256', checkout_request, secret_key) + "|" + checkout_request)

Open in new window


which isn't valid and its not exacly translation of the script.

When i test shell version with my secret key it works.
I tried Base64.urlsafe_encode64, encode64, strict_encode65, I tried digest instead of hexdigest. All kinds of way because I desperatly can't make it work. I think its about checkout_request data because it translates to this
 
2.5.0 :001 > '{"charge":{"amount":5,"currency":"EUR","capture":true}}'
 => "{\"charge\":{\"amount\":5,\"currency\":\"EUR\",\"capture\":true}}" 

Open in new window

and therefore signature is created with `\` before quote

question on stackoverflow: https://stackoverflow.com/questions/51506282/json-and-generating-signature
0
Hello,

Beautiful people of Experts-Exchange,

I have an app built on ruby on rails running on a Linode server. The app has iOS and android versions available as code in Bitbucket for source control.

The app uses cloud hosting on cloudspace.com and rackspace.com.

When I send text from one end to another for 2 registered users; it gets delivered. But when I send pictures; there is an image failure with only placeholder shown in receiver.

Log shows

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
  app/controllers/api/v1/users_controller.rb:16:in `auth_cloud'

The bucket has a users_controller.rb which (on branch 'auth_cloud') in api_server/app/controllers/api/v1 that looks like -

def auth_cloud
    uri          =  URI 'https://identity.api.rackspacecloud.com/v2.0/tokens'
    data         = { 'auth' => { "RAX-KSKEY:apiKeyCredentials" => { 'username' => '***' , 'apiKey' => '***' }} }
    json_headers = {"Content-Type" => "application/json", "Accept" => "application/json"}
    http   = Net::HTTP.new uri.host, 443
    http.use_ssl = true
    res    = http.post uri.path, data.to_json, json_headers
    if res                                                                                               //This is line 16
      data = JSON.parse res.body
      render json: { response: data['access']['token']['id'] }
    else
      render json: { error: 'could not auth to rackspace'…
0
im getting this error message in my ruby on rails blog app and i have no idea why

this is my controller file:

class PostsController < ApplicationController
  def index
    @posts=Post.all.order("created_at DESC")
  end

  def new
    @post=Post.new
  end

  def show
    @post=Post.find(params[:id])
  end

  def create
    @post=Post.new(post_params)
    if @post.save
      redirect_to @post
    else
      render "new"
    end
  end

  def edit
    @post=Post.find(params[:id])
  end

  def update
    @post=Post.find(params[:id])
    if @post.update(params[:post].permit(:title, :body))
      redirect_to @post
    else
      render "edit"
    end
  end

  def destroy
    @post=Post.find(params[:id])
    @post.destroy
    redirect_to posts_path
  end

  private

  def post_params
    params.require(:post).permit(:title, :body)
  end

end

Open in new window


and this is my edit file: (i get the error when trying to delete a post and the link to the destroy path is on my edit page)

<font color="#BD004B">
    <h1 class="smallBorder">Edit Post</h1>
</font>
<br/>
<hr size="10" width="auto" color="#BD004B">

<%=render "form"%>

<ul>
  <li>
    <%=link_to "Delete", posts_path(@post), method: :destroy, data:{confirm:"Are you sure you want to delete this post?"}%>
  </li>
</ul>

Open in new window

0
0
Hello, I see below script starting like

require 'MonitoringScript'
class CheckSnmp < MonitoringScript

Open in new window


I am wondering what is MonitoringScript ? is it gem? and what below does?

class CheckSnmp < MonitoringScript

Open in new window


Really appreciate any help and guidance.
0
A traveller searches for trips from Bern to Berlin on Dec 25, 2013, from 8am (one-way).
A list of the 20 first results returned by a tool is given in the attached ex3-data.json file.

Tips: most fields are self-explanatory, while some may need explanation:
1. boo_return is true for a return trip, false otherwise
2. workTime_sec is the duration that the traveler can work during that part of the trip in seconds.
3. duration_out_sec is the duration of the corresponding outbound part of the trip, in seconds. For return trip, if applicable, there will be a similar field duration_in_sec for the duration of the inbound trip part.

Goals
1. Propose a solution to rank the list of results provided in the attached file.
2. Output the list of ranked results to a file named ex3-output.json.
   Each result must have two additional properties “rank” and “score”, respectively storing the final rank and the score of the trip (If applicable).

========================================
ex3-data.txt
0
How difficult is it for someone to make an AI interface that can be used on my computer, that can access anything from google maps when asking where something is located (like siri) all the way to being able to scan a hard drive for the contents held within it? I work for this small company and all we do is use google maps and take old hard drives and scan them for their contents, upon request by customer, and retrieve data deleted, lost, or just unreachable due to computer malfunction. I want to see if there is an easier way to do this, by using an AI to do all the hard work, and all we have to do is tell it to scan the drive and collect the lost data and store it into either a zip file or something as such. Please let me know thoughts. Am also flexible, doesn't have to be in ruby, but a lot of things we do, we use ruby based programs that's why I'm curious if its possible.
0
I am trying to get a RoR application running on Ubuntu 15.10, the app runs on:
* Apache
* MySQL
* Ruby on Rails

Should I install Apache first, then CD to the Apache directory before installing rails? The reason I ask is there is one GEM that needs to be installed manually:
sudo gem install jquery-rails -v 3.1.4

Open in new window


I have just did a clean Ubuntu 15.10 and started installing Ruby, however I am thinking, should I have installed Apache first? Is there an order to installing RoR for Apache, where I need to be in the apache directories for GEM commands?

I am a Linux newbee, thanks in advance!
0
I am migrating an existing Ruby on Rails application.   I have setup a development environment in Ubuntu with Ruby 1.8.7 and Rails 2.3.12 and SQLite 2.8.17.

I would like to download the production source and install on the development computer.   What do I need to download and move?
0
I’ve been trying to find alternatives to using sleep for some time and it seems that every single suggested method to avoid using sleep never works and I’m at the end of my rope.

      it 'finds the correct product when searching by job type', js: true do
        fill_in('filterrific_for_work_type', with: 'Central')
        # once again, sleep feels like the only thing that works
        #sleep 1 # TODO: find a better way..
        expect(find('#work_queue_items_filter_reset')).to have_content('Reset All Filters')
        expect(page).to have_link('IP Central Report',
                                  href: work_queue_item_path(@release.id))
      end

Open in new window


I also have this wait for ajax helper:

module CapybaraHelpers
  def wait_for_ajax
    Timeout.timeout(Capybara.default_max_wait_time) do
      loop until finished_all_ajax_requests?
    end
  end

  def finished_all_ajax_requests?
    page.evaluate_script('jQuery.active').zero?
  end
end

Open in new window


And in spec_helper.rb:

RSpec.configure do |config|
config.include CapybaraHelpers, type: :feature
End

Open in new window


This test breaks unless I add the sleep 1.  and I’ve tried so many iterations using things like ‘within’ ‘find’, ‘have_content’ ect.  This is really driving me crazy.
0

Ruby

Ruby is an open-source dynamic object-oriented interpreted language that supports multiple programming frameworks including functional, object oriented and imperative. It also has a dynamic type system and automatic memory management. Ruby focuses on simplicity and productivity. Ruby's market share spiked due to Ruby on Rails, a model-view-controller (MVC) framework for building web applications.

Top Experts In
Ruby
<
Monthly
>