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

Date filter not displaying

Ruby
I created a new datetime row for a page, it works well. The column displays all the specific dates, but when I want to show specific rows using a date...
2 years ago

What is the `.html` used in ruby on rails?

Ruby
I see lots of code snippets that goes: respond_to do |format| format.html { something } format.json { something } end I'm wondering what the ht...
2 years ago

Rails 4 add file_field for attachment upload to existing form and controller

Ruby
I'm super new to rails. Been learning a few weeks now. Please excuse my idiocy. I cannot get my file I've selected to upload. I'm using Rails 4.0....
2 years ago

Rails Strong Parameters - what if one of my fields is optional?

Ruby
I'd not claim myself to be an expert in Rails by any stretch. One of the things that confuses me is Strong Parameters, and I've not found any really ...
2 years ago

How to strip leading and trailing quote from string, in Ruby

Ruby
I want to strip leading and trailing quotes, in Ruby, from a string. The quote character will occur 0 or 1 time. For example, all of the following s...
2 years ago

Ruby convert Object to Hash

Ruby
Let's say I have a Gift object with @name = "book" & @price = 15.95. What's the best way to convert that to the Hash {name: "book", price: 15.95} ...
2 years ago

Ruby: undefined local variable or method for Class

Ruby
I have what I assumed was a very simple method within my controller: class ReportsController < ApplicationController client = MWS.reports de...
2 years ago

Ruby initialize

Ruby
In the example below (source), class Greeter def initialize(name = "World") @name = name end def say_hi puts "Hi #{@name}!" end def...
2 years ago

Ruby Code navigation, reading tips and tools, how to locate a code in the file system, jump to and read

Ruby
This post has been edited. Considered deleting but decided otherwise since I needed this quite badly two months ago. Leave a comment if someone want...
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