Questions tagged [ruby-2.1]

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

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. Ruby 2.1 was released on Dec 25, 2013.

For information on Ruby in general, visit .

222 questions
0
votes
1 answer

ruby class#initialize manifold arguments

i don't understand. this one works: class Foo def initialize(*args) @variables = *args unless args[0].eql?(nil) end end this one don't: class Foo def initialize(*args) args[0].eql?(nil) ? @multiples = [3,5] : @multiples = *args …
jc newb
  • 5
  • 3
0
votes
1 answer

How to install rails version 4.0.4 and ruby version 2.1.1 on windows

my question is straight, Please give me answers with some details of the tools that I use. I have done some research and I am not getting a straight solution. I am trying to run a rails application that is using rails version 4.0.4 and ruby version…
ben
  • 6,000
  • 5
  • 35
  • 42
0
votes
1 answer

rack::offline in rails 4.1 Issue

can someone give me a quick solution please? I have done this: My routes: offline = Rack::Offline.configure do cache ActionController::Base.helpers.asset_path("application.css") cache…
ben
  • 6,000
  • 5
  • 35
  • 42
0
votes
1 answer

Ruby Process.daemon: turning on/off

I am trying to daemonize a Ruby script, running on 2.1.1. My daemon part of the code is like this: case ARGV[0] when "-start" puts "TweetSearcher started." Process.daemon when "-stop" Process.kill(9,Process.pid) else puts "Lacks arguments.…
sn0wtroopeer
  • 102
  • 2
  • 11
0
votes
2 answers

javascript Data.parse in ruby

I want to use HighCharts to render some historical data. The issue is the chart is working with dates which are parsed using Data.parse function. As explained here: The Date.parse() method parses a string representation of a date, and returns the…
gotqn
  • 42,737
  • 46
  • 157
  • 243
0
votes
1 answer

Not able to create a file for writing

I am uploading txt files using carrierwave. The files are not small (80 MB - 500 MB) and I want to remove some of the lines to reduce this size (about 80% of the file size is going to be reduced). I have created a model method in order to clear…
gotqn
  • 42,737
  • 46
  • 157
  • 243
0
votes
2 answers

Can the Ruby 2.1 shorthand for private/protected be used for class methods?

In Ruby 2.1, def now returns a symbol [1] pry(main)> def foo; end => :foo One cool use case of this is that because private and protected are methods that take a symbol and make the method private, you can now create a private method like…
MaxGabriel
  • 7,617
  • 4
  • 35
  • 82
0
votes
1 answer

I keep getting this error message even after I include attribute methods: match ? attribute_missing(match, *args, &block) : super

I am trying to get my Posts controller to work and I keep getting these error messages: undefined method 'each' for `#` and : match ? attribute_missing(match, *args, &block) : super I just included Attribute Methods but…
tomcruise
  • 17
  • 1
  • 7
0
votes
2 answers

Wrong number of arguments error(1 for 0) in Posts controller, rails 4?

I am getting the error message "wrong number of arguments error(1 for 0) in my posts controller in my show action. I will comment the end of that specific line. Thanks for the help. def show @post = Post.all(:order => 'created_at DESC') #this is…
tomcruise
  • 17
  • 1
  • 7
0
votes
1 answer

Can't get f.globalize_fields_for to appear using globalize 4.0.2 ruby gem

I'm using rails 4.1.4 and ruby 2.1.2, globalize 4.0.2, batch_translations 0.1.3 (I couldn't get f.globalize_fields_for to work any other way than use this gem), i18n 0.6.11 and friendly_id 5.0.1. In posts/_form.html.erb, I have…
Pavan Katepalli
  • 2,372
  • 4
  • 29
  • 52
0
votes
3 answers

Rails query: Compare calculation of two attribute values

I have a model, Product, which has both a :created_at timestamp and an :expiration_in_days attribute. Products are considered expired a certain number of days after their creation. How do I write a query that only returns products that have not…
steel
  • 11,883
  • 7
  • 72
  • 109
0
votes
1 answer

rails 4 premit for array

little bit confuse in permit HI I am using rails 4.1.1 & ruby 2.1.2 Params "user_experienced_non_it"=>[{"experienced_non_it_reg_id"=>"132", "experience"=>"2years", "remark"=>""}] Controller code: def user_experienced_non_it_params …
Siva KB
  • 357
  • 1
  • 6
  • 19
0
votes
1 answer

Helper method rendering only the last link of a list

I have this helper method: def pick_index_paths_new case params[:type] when 'eood', 'ood' content_tag :li , :class => 'link_list' do link_to "New EOOD", new_eood_path link_to "New OOD" , new_ood_path end …
Hristo Georgiev
  • 2,499
  • 1
  • 16
  • 23
0
votes
2 answers

upgrade ruby on rails application

Currently my application run on rails 3.1.3 & ruby 1.9.3. I want to upgrade my application into rails 4.1 & ruby 2.1 Can anyone tell me how to upgrade the rails application ? Thanks in advance
Siva KB
  • 357
  • 1
  • 6
  • 19
0
votes
1 answer

Ruby 2.1.1 ArgumentError when passing hash before keyword arguments

In Ruby 2.1.1 I defined the following method: def post(url, params={}, send_json: false, success_only: true) This is called within the same object in another method privateToken like so: self.post("#{@url}/api/v3/session", { :login …
KomodoDave
  • 7,239
  • 10
  • 60
  • 92