ruby

How can I uninstall Ruby on ubuntu?

How can I uninstall Ruby on ubuntu? Need to reinstall - please help ...

How Do I get searchlogic to work with rails 3?

I put searchlogic in my gemfile... and now my rails server won't start :( this is the errormessage gems/ruby-1.8.7-p299/gems/activesupport-3.0.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `merge_joins' for class `Class' (NameError) from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/activesup...

RVM, Rails Errors

I installed RVM, then used it to install ruby-1.9.2 and then used rubygems to install rails 3.0. It lets me create a new app but then when I change to the app's root and attempt to generate a scaffold I get this error: Could not find gem 'sqlite3-ruby (>= 0, runtime)' in any of the gem sources. Try running `bundle install`. So then I ...

DateTime with MongoDB/Mongoid and Rails 3 Not Populating

Here is the code in my Model include Mongoid::Document include Mongoid::Timestamps field :message, :type => String field :send_at, :type => DateTime Here is the code for my form partial <%= f.label :send_at %><br /> <%= f.datetime_select :send_at %> But the date and time is never populated. I made sure that Mongo and Mongoi...

problem with bundle

I try command bundle install --local but it show issue: -bash: /usr/local/bin/bundle: /usr/local/bin/ruby: bad interpreter: No such file or directory. please help me. ...

Continuous Integration for all version ruby?

I'm know CruiseControl.rb used for Continuous Integration but it Prerequisites ruby 1.8.6. please sugguest me a lib sloved for all version ruby. Thanks http://cruisecontrolrb.thoughtworks.com/documentation/getting_started ...

In Ruby is there a way to overload the initialize constructor?

In Java you can overload constructors: public Person(String name) { this.name = name; } public Person(String firstName, String lastName) { this(firstName + " " + lastName); } Is there a way in Ruby to achieve this same result: two constructors that take different arguments? ...

ActiveRecord/MySQL query to return grouped set of objects

I have a model called a Statement that belongs to a Member. Given an array of members, I want to create a query that will return the most recent statement for each of those members (preferably in one nice clean query). I thought I might be able to achieve this using group and order - something like: # @members is already in an array @...

How do i provide chunked transfer encoding

Sorry for asking this again but i did n't get any answer so i am asking ,i have rails application thats uploading some large file (2gb) but these upload are only possible with google chrome but using Internetexplorer only 1 gb of file being uploaded after that meas more than 1.5 gb IE throwing saying like Internet Explorer cannot displa...

Vim Question Regarding Views

I have been reading a lot of the questions here on vim. I can't locate something that I want to do with vim but I am sure its possible. I like vim(I am still new at it) using tabs and I have adjusted my vimrc so that H & L keys take me back and forth between tabs. I was hoping to find a way to be able to use tab commands to open up a t...

Alias for array or hash element in Ruby

Example for array arr = ["a", "b", "c"] # TODO create an alias for arr[1] as x x = "X" # arr should be ["a", "X", "c"] here Example for hash hash = { :a => "aaa", :b => "bbb" , :c => "ccc" } # TODO create an alias for hash[:b] as y y = "YYY" # hash should be { :a => "aaa", :b => "YYY" , :c => "ccc" } here And also an alias for a v...

Ruby 1.9 Array.to_s behaves differently?

i wrote a quick little application that takes a base file of code with some keywords, a file of replacements for the keywords, and outputs a new file with the keywords replaced. When i was using Ruby 1.8, my outputs would look fine. Now when using Ruby 1.9, my replaced code has the newline characters in it instead of line feeds. For e...

Ruby: block for min / max function

Hi, let's say I have the following array: arr = [[5,1], [2,7]] and I want to find the minimum comparing the second element. i.e. The minimum will be [5,1] (since 1 is less than 7). I can use the following code: arr.min {|a,b| a[1] <=> b[1]} For calculating the maximum I can do the same: arr.max {|a,b| a[1] <=> b[1]} That gives...

Can't use ActiveRecord associations Rails 3 in IRB

I have three classes with the following associations: class Technician < ActiveRecord::Base has_many :tickets has_many :services, :through => :tickets end class Ticket < ActiveRecord::Base belongs_to :technician has_many :services end class Service < ActiveRecord::Base belongs_to :ticket belongs_to :technicians end W...

Can the Sequel Gem connect to MySQL over SSL

Hi Does anyone have any information on how to connect from the sequel gem to a remote mysql database over ssl? I can connect without ssl but trying to connect as a user who requires ssl just fails with the error message: Sequel::DatabaseConnectionError: Mysql::Error Access denied for user 'ssl_user'@'<IP_ADDRESS>' (using password: YES...

Rails passing @variable from one show page to another

I have a Gallery application that has Album and Photo models. I have the user search in the Album's show view (search in the specific album) and I store the results in a variable named @search in the show action of the controller. I want to pass this variable to the Photo model's show page so when a user clicked on a particular pictur...

dynamically generate an attribute on an object, ruby, rails

Given these params: ex: 1 {:field => 'admin', :id => "1"} ex: 2 {:field => 'client', :id => "1"} ex: 3 {:field => 'partner', :id => "1"} Is it possible, (and how of course) could i dynamically apply this to the User model such as: controller #note the field attribute is not a field #the field attribute I'm trying to set above...

How to avoid ActiveRecord::RecordNotFound exceptions when querying multiple records

I have this code: Article.find([1,2,3]) But only record 1 and 2 exist in the database. I get this exception: "ActiveRecord::RecordNotFound (Couldn't find all Offers with IDs (1,2,3) (found 2 results, but was looking for 3))" Is there a way to only get the existing records and not the exception? ...

Converting a C struct to FFI::Struct

I am having difficulty setting up a struct from the pcap library in FFI. Struct: struct pcap_if { struct pcap_if *next; char *name; char *description; struct pcap_addr *addresses; bpf_u_int32 flags; }; The relevant Ruby code module Pcap extend FFI::Library ffi_lib 'pcap' attach_function :pcap_findalldevs,[:pointer,:...

Ruby: How can I process a CSV file with "bad commas"?

I need to process a CSV file from FedEx.com containing shipping history. Unfortunately FedEx doesn't seem to actually test its CSV files as it doesn't quote strings that have commas in them. For instance, a company name might be "Dog Widgets, Inc." but the CSV doesn't quote that string, so any CSV parser thinks that comma before "Inc." ...