ruby

Ruby gem LoadError - rubygems/defaults/operating_system

Hello, I've installed ruby 1.8.6 p368 and gems 1.3.4 as well as required libraries like zlib, ssl or readline on my winxp sp3 box. The problem is, when I now try to use some gem, I get the following error: Exception `LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1112 - no su ch file to load -- rubygems/defaults/operating_syst...

Controlling Merb authentication errors

Hey there, im a little bit confused about handling invalid user authentication request, at login controller. So, i already have modified login view, but cant figure out where to put the exception handling block. It should work like this: you login - if its incorrect you will see warning message at /login . Any ideas ? ...

Can't seem to run 'scaffold :product' in my controller.

Hey guys, I recently started with the 'Agile web development with Rails' book by pragmatic programmers after having some early experience with rails but wanting a more structured approach. I'm happily following the book when they ask me to make a controller admin so I can edit the standard CRUD product model I already created. Accordin...

Unable to rescue from "Lost connection to MySQL server" error

I have a block like so: begin # some SQL request rescue Mysql::Error => e logputs "Mysql::Error occurred, retrying in 10s: #{e.message}" sleep 10 retry end But when a "Lost connection to MySQL server" error occurred, this block was not able to catch it and retry (the MySQL server was restarted). Any idea how I ...

Why does form_helper assume that it should call active_record_helper?

This code in my view triggers an error: <% remote_form_for(mymodel) do |f| %> <%= f.error_messages %> (mymodel is not an ActiveRecord object) When I look at the error trace, I see this section which indicates that error_messages in the view translates into error_messages_for in the active_record_helper: C:/Ruby18/lib/ruby/gems/1.8...

how does cairngorm+flex integrate with rails?

I mean, the mvc for cairngorm and the one in rails don't overlap their functionalities? I'm not sure I understand the need for cairngorm with the rails backend.. ...

MySQL/Ruby on Windows

I am trying to use Rails 2.3.2 with MySQL 5.0 on Windows XP with no luck. I have installed MySQL and am able to run it, add tables etc. In ruby, the require 'mysql' statement passes but onde it reached the first action then I get > C:/Development/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql...

Own encoding

How can i create my own encoding in ruby(1.9)? - for converting string while reading/writing from/for a file, i.e. generally for manipulating data in nonstandard encoded strings (http://en.wikipedia.org/wiki/Mazovia_encoding) ...

How does this deprecate method work?

I was trying to understand this call: deprecate :new_record?, :new? which uses this deprecate method: def deprecate(old_method, new_method) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{old_method}(*args, &block) warn "\#{self.class}##{old_method} is deprecated," + "use \#{self.class}##{...

Is it good style to explicitly return in Ruby?

Coming from a Python background, where there is always a "right way to do it" (a "Pythonic" way, if you will) when it comes to style, I'm wondering if the same exists for Ruby. I've kind of been using my own style guidelines but I'm thinking about releasing my source code, and I'd like it to adhere to any unwritten rules that might exist...

How do I get IRBRC running on Win32 for Ruby console?

Can anyone suggest some troubleshooting approaches for getting IRBRC running under Win32? The rails console is an awesome tool and I'm attempting to extend it with more functionality. For instance, I would like the what_method gem to load automatically. The gem is installed but it does not load: C:\...\trunk>ruby script\console Loa...

What could prevent the creation of a gem specification file?

I tried to update the specs on a gem that didn't have a .specification file. 1. cd {application_home_directory} 2. rake gems:refresh_specs When I did, I received the recursive warning: config.gem: Unpacked gem in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. I've also tried this, which also fail...

How to get the 'current observation data' from the NDFD (NOAA, NWS) REST service?

Hi All, I'm trying to use the NDFD (National Digital Forecast Database) to get current temperature and relative humidity given a Lat and Long using their REST based service. The issue at hand: I can't match the 'current observation data' WITH the 'results' I get back from the REST-service. The setup: Location: * Apple (1-infinite lo...

Why is a gem specification needed and why do some gem creators not provide them?

I've noticed some ruby gems have .specification files and others don't. If they're important, why are you not required (by whatever tool builds them) to provide one when you attempt to create your gem? ...

Reading a File with Ruby

I have a text file that contains a list of regexp's which I regularly use to clean html files according: list.txt <p[^>]*>|<p> <\/?(font|span)[^>]*>| <\/u>\s*<u>| <\/u>\s*<i>\s*<u>|<i> if each line consisted of the form "#{a}|#{b}", what would be the simplest way to both read and convert this file into the array: [ [ /<p[^>]*>/, '...

environment first or boot first?

environment.rb starts with this: RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| Does this mean environment.rb starts first and calls boot.rb? ...

Creating customized label fields in forms.

I'd like to be able to generate the following markup: <label for="field">Something <span class="hint">Field hint</span></label> from the following code: form_for ... do |f| f.label :field, :hint => "Field hint" end So far I've created an initializer to store the custom functionality which re-opens ActionView::Helpers::FormBuild...

How do I call Windows DLL functions from Ruby?

I want to access functions within a DLL using Ruby. I want to use the low-level access of C while still retaining the simplicity of writing Ruby code. How do I accomplish this? ...

How can you validate the presence of a belongs to association with Rails?

Say I have a basic Rails app with a basic one-to-many relationship where each comment belongs to an article: $ rails blog $ cd blog $ script/generate model article name:string $ script/generate model comment article:belongs_to body:text Now I add in the code to create the associations, but I also want to be sure that when I create a c...

How do I find overlaps between two Ruby Runt patterns?

I am developing a Google like calendar on Rails and am using Runt to define the recurrence patterns for creating events. However, the restriction with the calendar is that there cannot be two events for same time slot. So, if i have an event created with event = REDay.new(13,00,15,00) # daily between 1PM to 3 PM Then the application...