how to convert html pages into erb in Rails?

Ruby
I have been given the task to convert some static html page into erb page , to be used in a Rails project. Since, all page belongs to same project, th...
2 years ago

windows_zipfile Chef resource failing due to 'rubyzip' gem file download

Ruby
We are facing a situation, where end users Windows VM does not have internet connectivity, but only have access to file store. We are using windows_...
2 years ago

Check if a specific key is present in a hash or not?

Ruby
I am working in Rails and I want to check whether the "user" key is present or not in the session hash. How can I check this? Note that I don't want ...
2 years ago

ruby - refactoring if else statement

Ruby
I've tried reading some tutorials on refactoring and I am struggling with conditionals. I don't want to use a ternary operator but maybe this should ...
2 years ago

Merge Complex Hash of Arrays of Hashes Simultaneously on Multiple Levels

Ruby
I realize there are many questions of varying degrees of similarity to this one. I've searched at length (using: [ruby] merge array of hashes on key)...
2 years ago

Best way to generate order numbers for an online store?

Ruby
Every order in my online store has a user-facing order number. I'm wondering the best way to generate them. Criteria include: Short Easy to say over...
2 years ago

Dynamic method calling in Ruby

Ruby
As far as I am aware there are three ways to dynamically call a method in Ruby: Method 1: s = SomeObject.new method = s.method(:dynamic_method) meth...
2 years ago

Sending post request from rails with rest_client.. 400 Bad request

Ruby
Basically, I want to send post request to a faye server. When I use curl, It works, curl http://localhost:9292/faye -d 'message={"channel":"/messages...
2 years ago

Rails, create an object when another instance is accessed or created

Ruby
I'm a Rails newbie and I'm to handle a situation for the first time. I have an ActiveRecord class, Video. class Video < ActiveRecord::Base def...
2 years ago

Merging Ranges using Sets - Error - Stack level too deep (SystemStackError)

Ruby
I have a number of ranges that I want merge together if they overlap. The way I’m currently doing this is by using Sets. This is working. However, wh...
2 years ago

Ruby Methods and Optional parameters

Ruby
I'm playing with Ruby on Rails and I'm trying to create a method with optional parameters. Apparently there are many ways to do it. I trying naming th...
2 years ago

How to create a directory with a slash '/' in its name

Ruby
For example, I want to create a folder named "AC/DC". What should I do? Dir.mkdir("AC/DC") will give an error message like this in `mkdir': No suc...
2 years ago

How do I pass a hashmap of options to a rails method?

Ruby
Say I have a hash of m = {data:{toggle:true}, class:"btn btn-success"} I want to pass this hash directly to the link_to method. Something like: l...
2 years ago

Canonicalizing JSON files

Ruby
I have a bunch of automatically generated JSON files that I want to store in version control. The problem is that each time the files are serialized,...
2 years ago

Converting Sql Query to Rails Syntax

Ruby
I am having trouble in converting this query to Rails syntax. would any one please guide me SELECT "users".* FROM "affiliates" INNER JOIN "...
2 years ago

Ruby - Comparing each line in CSV file to JSON hash on matching element -- unique matches only

Ruby
I am starting to learn Ruby and write my own code without help but I am still relatively new at this. I searched SO before posting but perhaps I don'...
2 years ago

Comparing each line in CSV file to JSON hash on matching element to get unique matches only

Ruby
I searched SO before posting but perhaps I don't know the correct search terms. I successfully read the CSV file into a new array and am trying to co...
2 years ago

Test module method with rspec-mocks

Ruby
How to test config method in this module with Rspec 3 mocks? module TestModule class << self attr_accessor :config end def self.confi...
2 years ago

How to display the values of nested attributes in my views ?

Ruby
I'm starting with Ruby and i got some issue to display the infos in my views. Here is my code: e app/models/user.rb class User < ActiveRecord::Ba...
2 years ago

Rspec to have(n).items undefined method

Ruby
I'm trying to follow a guide on code.tuts and I keep getting an error. Here is my Library spec: require 'spec_helper' describe Library do before ...
2 years ago