Rails, best way to save one value asked from admin

For example, I have Post model in my Ruby on Rails application. And I want to create a way that user without code experience could set expiration date for all posts on production. What I mean, for example, Post was create at 21:00 and admin wants t...
more »

2017-05-14 20:05 (3) Answers

How to document a Padrino application using Yard?

I'm using Padrino - which builds on top of Sinatra 2.0.0 - as well as ActiveRecord 5.1.1 and RSpec 3.6.0 gems. How do I generate (meaningfull) documentation using Yard for a Padrino application? I tried invoking yardoc with several differen...
more »

2017-05-14 19:05 (0) Answers

Leap year exercise (Chris Pine): Help/review

I'm brand new to programming and just working through the "Leap Year" exercise on Chris Pine's site. Is including the following code in my while loop the correct way to approach this? and start = start.to_i + 1 I can't get the program to puts the...
more »

2017-05-14 09:05 (2) Answers

Ruby Case class check

I'm new to Ruby. How can I get the following code to work (I want to decide upon an action based on the class of the arg): def div arg material = case arg.class when String [arg, arg.size] when Fixnum ...
more »

2017-05-13 22:05 (2) Answers

Error when running my application

I have reinstalled my operating system and installed all the necessary libraries and components to run rails, but at the moment of running my application it shows me the following error: /home/luis/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spro...
more »

2017-05-13 16:05 (0) Answers

An object as a parameter/argument in Ruby?

I've been messing around in Ruby, thinking of making simple little RPG games. It's been going decently (already have character creation mostly done). But, I was having trouble finding out how to make an attack method (or other kinds of targeted metho...
more »

2017-05-13 15:05 (1) Answers

How to set cookies using form

I don't have an idea how to implement simple CRUD using cookies. First question: What to put instead of @user? I have only this: My form: <%= simple_form_for @user do |f| %> <%= f.input :first_name %> <%= f.input :last_name %>...
more »

2017-05-13 15:05 (1) Answers

Install a Ruby gem to an arbitrary prefix

I'd like to install a Ruby gem to an arbitrary prefix. For the sake of exposition, I'm trying to install github-markup; though, I suspect I'm encountering a general issue rather than anything particular to this package. In the package's source dist...
more »

2017-05-12 22:05 (0) Answers

How does the enumerator receive a block?

I have: letters = %w(e d c b a) In the following: letters.group_by.each_with_index { |item, index| index % 3 } #=> {0=>["e", "b"], 1=>["d", "a"], 2=>["c"]} how can the enumerator returned by group_by know the block it will execute? ...
more »

2017-05-12 01:05 (1) Answers

SSL wildcard certificate common name

I would like to know the common name i must put on a wildcard certificate because i created a csr and put the code on the website to activate using the *.exemple.com and did not validated Common Name (eg, YOUR name) []:*.example.com someone know ...
more »

2017-05-12 01:05 (0) Answers

RVM install ruby into a different directory

I am trying to install several versions of ruby using rvm (multiuser install) and want to have the different ruby versions in specific folders, for ex. /opt/ruby-1.9.2, /opt/ruby-2.0.0, /opt/ruby-2.1.10 Is there a install configuration argument that ...
more »

2017-05-12 00:05 (0) Answers

Logic to simplify item replacement chain

I have some items that are being replaced by other items hence creating a replacement chain as: +---------------+------------------+ | Replaced Item | Replacement Item | +---------------+------------------+ | A | B | | B ...
more »

2017-05-11 15:05 (1) Answers

remove and reinstall rubygems (reinstall RVM)

I ran into a problem with some gems, so I was told I should remove them with rm -rf ~/.rvm. What do I have to do now in order to reinstall the gems? I instinctively ran bundle install in the directory where my Gemfile is, but, of course, it gives me...
more »

2017-05-11 14:05 (2) Answers

Error after rails migration 4.2.6 to 5.1.0

I have migrated one of my rails project from 4.2.5 to 5.1.0 I follow this tutorial for migration: https://hashrocket.com/blog/posts/how-to-upgrade-to-rails-5 After migration when I run rails db:migrate I found following error. NoMethodError: undef...
more »

2017-05-11 05:05 (2) Answers

Use other facts in a custom fact

I am having a tough time with the following custom fact; details below. The custom fact needs to look for a certain json file in the following folder. This displays the information when used within a manifest. But, when I add it to the custom fact, ...
more »

2017-05-11 03:05 (1) Answers