ruby

Writing a Jeweler Rakefile that adds dependencies depending on RUBY_ENGINE (ruby or jruby)

I have a Rakefile that includes this: Jeweler::Tasks.new do |gem| # ... gem.add_dependency('json') end The gemspec that this generates builds a gem that can't be installed on jruby because the 'json' gem is native. For jruby, this would have to be: Jeweler::Tasks.new do |gem| # ... gem.add_dependency('json-jruby') end How ...

last_login_at not working (null) w/ Authlogic Magic Columns...

I am using the Authlogicgem for authentication and most of it seems to be working great. Authlogic provides several columns that you can add to your Users table (for example) that it knows to fill in if they are present. i.e. login_count, current_login_ip, last_request_at and last_login_at. All seem to be working fine with the exceptio...

Add api key to every request in ActiveResource

I have 2 RESTful Rails apps I'm trying to make talk to each other. Both are written in Rails 3 (beta3 at the moment). The requests to the service will require the use an api key which is just a param that needs to be on every request. I can't seem to find any information on how to do this. You define the url the resource connects to via...

Headers on the second row in FasterCSV?

G'day guys, I'm currently using fasterCSV to parse a CSV file in ruby, and wondering how to get rid of the initial row of data on a CSV (The initial row contains the time/date information generated by another software package) I tried using fasterCSV.table and then deleting row(0) then converting it to a CSV document then parsing it bu...

Implementation for already available classes in Ruby

Hi All, I am a Java Developer and a newbie in Ruby. Does Ruby not implement available classes in Ruby lang itself(as done in Java). Actually I have downloaded the code for Ruby and was trying to find the implementation for classes like Fixnum, etc. But could not find it. ...

XMLRPC with long integer entry in hashMap from java server is not obtained in ruby client

I am using XMLRPC to get data from a Java server. I use HashMap as return value for a particular remote call. The server puts a long int into the HashMap (which is returned) along with other data. At the client end, which is ruby, I get all other data but for the long int. How can I get this data at the client? ...

Error installing FeedZirra

Hi, I am new to Ruby on Rails. I am excited about Feed parsing but when I install FeedZirra I am getting this error. I use Windows 7 and Ruby 1.8.7. Please help. Thanks in advance. C:\Ruby187>gem sources -a http://gems.github.com http://gems.github.com added to sources C:\Ruby187>gem install pauldix-feedzirra Building native extensio...

Cannot install Fast debugger in Netbeans 6.8 for Ruby 1.9

Hi, I am using Netbeans 6.8 version and Ruby 1.9.1 installed on Windows XP. I tried to install the fast debugger and I am getting the following error. Building native extensions. This could take a while... ERROR: Error installing ruby-debug-ide: ERROR: Failed to build gem native extension. D:/Ruby19/bin/ruby.exe m...

How to install curl on windows for ruby on rails

Hi, I am new to ruby on rails. Could you please help me to install curl. I have windows 7 and ruby 1.8.7 I need to install Paul Dix's FeedZirra. I need curl for that. Also could you help me with gem install curb. Even curb seems to need Curl Looking forward for your help Thank You Gautam ...

Is there any good best practices for exception handling in rails?

I'm currently on Rails 2.3.5 and I'm trying rescue_from exceptions as neat as possible in my Application. My ApplicationController rescues look like this now: rescue_from Acl9::AccessDenied, :with => :access_denied rescue_from Exceptions::NotPartOfGroup, :with => :not_part_of_group rescue_from Exceptions::SomethingWentWrong, :wit...

Looping through an array while adding the data to a string and finally returning it, a faster way?

Getting the customer's to_s method by looping through Is there a Ruby idiom to write the code in 1 line (or shorter than 3 lines of code)? def method string = "" @customers.each { |customer| string += customer.to_s + "\n" } string end ...

Rail 3 escaping maruku

I am using Maruku with my RoR3 app. But the problem is that when i use the h(text) method to escape the text from the database before i use Maruku it escapes > to > so Maruku wont see this as a blockquote. But i still want to escape the rest of the text so my question is how can i make this work? I don't want to disable the escapin...

How to add a new custom resource to routes Rails 3

How do I add a custom route for a new resource in the Rails 3 routes? I know how to do it for collections and members but this style doesn't seem to be working for new resources. Is this a bug or am I doing something wrong? So these work: collection do get :wish end member do get :wish end But this doesn't work: new do get ...

how to refactor tricky logic involving consecutive sets?

The rule at work here is that users can be awarded badges for a streak of 10, 20, and 30. But the user can't be awarded multiple badges for the same streak. I'm tracking consec wins in the user model. For example, if the user hits a 10-streak, the user is awarded a 10-streak badge. If the user is on a 20-streak, he/she receives a 20-s...

adding class methods to ActiveRecord::Base

I have created an instance method which is also a callback (if that makes sense) which does some stuff thats irrelevant. I would love to be able to just call: class Model < ActiveRecord::Base fix_camelcase_columns end Instead at the moment I have this: def after_find self.class.columns.each do |column| self.instance_eval("d...

IronRuby as scripting language in .net

Hello anyone! I want to use IronRuby as scripting language (as Lua, for example) in my .net project. For example, I want to be able to subscribe from ruby script to specific events, fired in host application, and call ruby methods from it. I'm using this code for instantiate IronRuby engine: Dim engine = Ruby.CreateEngine() Dim source...

[Selenium] how do I assert that a hyperlink points to a given URL?

I am using Selenium IDE and Selenium RC to check links on a website, but I am having trouble finding a way to assert that a link points to a specified url and has the specified text. Constraints: locating the element by dom or xpath is not feasible for it will make the test brittle there are multiple link elements with identical link...

Store cookie from HTTP header

How do you store a cookie with basic info. i.e. link is http://www.domain.com/index.html?ref=123 How would I store a cookie with name of "ref" and the value of "123"? ...

How are $LOAD_PATH and $: different?

I needed to know what was in my Ruby load path, so I did this: $ ruby -e "puts $LOAD_PATH" It didn't print anything out, which I didn't expect. So I tried this: $ ruby -e "puts $:" /usr/local/lib/site_ruby/1.8 /usr/local/lib/site_ruby/1.8/i486-linux /usr/local/lib/site_ruby/1.8/i386-linux /usr/local/lib/site_ruby /usr/lib/ruby/vendo...

Rails caches_page, XML, and RESTful APIs

My app exposes a RESTful API using map.resources (eg: map.resources :comments). My comments controller caches_page :index, :show. In this way, I expose an XML API, so that a Flex app can post new comments. (eg POST to /comments.xml). This all worked fine until I enabled caching using the default filesystem store. Now, as far as I can ...