Questions tagged [ruby-1.9.3]

For issues relating to developing in Ruby, version 1.9.3. If your question applies to Ruby in general, use the tag [tag:ruby].

Related tags

495 questions
0
votes
1 answer

Optimization when transiting through states (tail recursion optimization)

When I have a code that transits through finite states for arbitrary many times as in the following example, def a ... case some_condition when :foo then a when :bar then b else c end end def b ... case…
sawa
  • 165,429
  • 45
  • 277
  • 381
0
votes
1 answer

Overwriting part of a string

Is there a simple way to overwrite a string, something like the following, or something similar? s = "123456" r1 = "abc" s.loverwrite(r1) # => "abc456" s.coverwrite(r1) # => "12abc6" (or "1abc56") s.roverwrite(r1) # => "123abc" r2 =…
sawa
  • 165,429
  • 45
  • 277
  • 381
0
votes
1 answer

Validation to model either this or that but must have one Rails?

I have 3 Models class Audio end class Album end class Movie end I want to have validation in Audio model.That while creating Audio the server should validate that the audio is linked with the album or movie or both. But both the fields selecting…
0
votes
2 answers

Problems with Macports Ruby19 Install

I'm learning Rails and fairly new to Macports. I receive the following error when running rails server for my project: /...config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end I believe this syntax error is caused by…
benedict_w
  • 3,543
  • 1
  • 32
  • 49
0
votes
1 answer

Print require time for booting up

How do I print the require time of my files so that I can debug a slow application boot time. I envision something like this: $ rails s $ app/models/user.rb took 300 milliseconds $ ... $ lib/connect.rb took 5000 milliseconds Would I have to…
maletor
  • 7,072
  • 7
  • 42
  • 63
0
votes
2 answers

Merge and convert arrays to hash in Ruby

There are 4 arrays in Ruby array1 = ["label1.1", "label1.2", "label1.3", "label1.4"] array2 = ["data1.1", "data1.2", "data1.3", "data1.4"] array3 = ["label2.1", "label2.2", "label2.3", "label2.4"] array4 = ["data2.1", "data2.2", "data2.3",…
user266003
0
votes
1 answer

Parsing date in Ruby

I need a date of birth as a plain text in Ruby on Rails application. So here is the main part of a code I'm using to do it if @date_of_birth_as_text.present? and Date.parse(@date_of_birth_as_text).nil? errors.add :date_of_birth_as_text,…
user266003
0
votes
1 answer

Can't mass-assign protected attributes issue using devise signup form

I am using rails 3.1 and ruby 1.9.3 for my application. And the issue is, I am getting "Can't mass-assign protected attributes" while saving the details. I have User model as: class User < ActiveRecord::Base # Include default devise modules. Others…
0
votes
1 answer

How to inspect Module#initialize?

I have defined a module Vehicle such that module Vehicle def initialize(make, model) end def start end def stop end end I want to inspect the instance methods defined in Vehicle using Module#instance_methods and Module#instance_method…
Mike Bradford
  • 240
  • 2
  • 10
0
votes
2 answers

Rails 3 and Bootstrap 2.1.0 - can't fix my footer

I have Rails application with bootstrap 2.1.0 (i use twitter-bootstrap-rails gem for that). But i can't get working footer. It is not visible unless i scroll down the page. I can't get how to fix that. Application.html.haml !!! %html %head …
0
votes
2 answers

Passing Multiple Parameters in a form_tag

I'm using Rails and jqPlot to display some data on a webpage. The graph needs to be flexible by date (as in, the user can select a time range, and the graph will update itself). Here's my code so far (in my View): <%= form_tag…
XML Slayer
  • 1,530
  • 14
  • 31
0
votes
2 answers

Kernel.lambda() not returning a lambda Proc in Ruby 1.9

I'm writing a simple event bus to use in an application. This part works fine: #!/usr/bin/env ruby module EventBus @callbacks = {} module_function def on event, &callback @callbacks[event] ||= [] @callbacks[event].push callback …
bkconrad
  • 2,620
  • 3
  • 20
  • 30
0
votes
1 answer

Add unique key values to a hash and creating a dictionary out of it

I am a beginner trying to learn ruby and I am writing a code for following problem statement: - Create a dictionary which is initially empty. - add entries to it.. the word should be the key and meanings should be values. - add whole entries with…
0
votes
3 answers

RegEx, How to get all matches and group? Ruby 1.9.3p125

Let's say I have the following string: google-com, Awesome-net(Ooops), facebook-com / rocket-yet I want to extract all the words ending with -com but have them grouped. For now, I have tried: ^\w+[-]com That works fine but only catches the first…
Kleber S.
  • 8,110
  • 6
  • 43
  • 69
0
votes
1 answer

ActiveRecord Delete...?

I'm just starting to learn ActiveRecord, and I am just trying out little things to figure out how everything works. I just tried the following code on the following sqlite3 database. Ruby: class Balances < ActiveRecord::Base def initialize …
Bobby Tables
  • 1,154
  • 4
  • 15
  • 25
1 2 3
32
33