ruby

How do I set Ruby Sequel logging to the DEBUG level?

The default Ruby Sequel behaviour is to log all DB queries at the INFO level (unlike ActiveRecord which logs at the DEBUG level). How do I change this? ...

How can I run Ruby specs and/or tests in MacVim without locking up MacVim?

About 6 months ago I switched from TextMate to MacVim for all of my development work, which primarily consists of coding in Ruby, Ruby on Rails and JavaScript. With TextMate, whenever I needed to run a spec or a test, I could just command+R on the test or spec file and another window would open and the results would be displayed with t...

undefined method `to_sym' for #<Tempfile in render :nothing => true

I am responding to a POST from a server that I don't control, and all the params[] come in as Tempfiles - which I can work around. (I am running on thin here at my desktop mac). The whole method works, but at the last line I have: render :nothing => true As there is nothing to render. It is in this render :nothing => true call that rai...

how so i find using the condtion in ruby

I have this @project.posts.count => 11 @project.articles.count => 5 >> a = @project.articles.map(&:signup_id) => [6, 8, 10, 12, 14] I want to only display the project posts that dont have an id of the following [6, 8, 10, 12, 14]. So i want display the posts that dont have an article.signup_id @project.posts #so reject if id is ...

Facebook in ruby, not rails!

Hi, I'm making a Cross-platform mobile app, with the fantastic framework "Rhodes". But how am i getting people to connect through facebook..? So what i wan't is, people should connect to facebook first in the application, and when they done that, it shoulld sync with the facebook app(that app, are made). So i just want to make a connect...

Ruby: Soap4r: How do I get the raw request sent to my soap server?

I have a connection open and am doing: values = [1, 'test'] connection.return_response_as_xml = true response = connection.send(method_name.to_sym(), *values) and that works fine and all. but I want to see the raw request sent across... is this possible? ...

Why is this not rejecting my records

>> a => [6, 8, 10, 12, 14] >> @project.posts(:all, :conditions => [ "id not in (?)", a ]) => [#<Post id: 6,........ Why is this not filtering the POst with id of 6 ...

How is event-driven programming done?

My question is pretty simple: how is event-driven programming actually achieved? To elaborate: I have a Rails application, every time a user makes a change on the website, the model writes that "change" to a text file (as JSON.) What I'd like to do is hook an IRC bot to that "event." (the creation/modification of the text file.) How i...

How can I get click events to work when chaining elements in Watir?

I am attempting to set up some UI testing in Watir for our web application. I'm running into trouble getting the click events to propagate. We are using EXTJS to make tabs, which are spans in the resulting html. If I select a span like this it works: span1 = @browswer.span(:text=>"Tab Name") span1.click The trouble is when I have...

Bit banging in ruby

I want to create a bit, that will contain security permissions for a given user. In c#, I would do this by creating an enumeration, and then I would do some bit banging on the binary value, by anding '&&' to see if it results in a TRUE value. How can I do this best in Ruby? ...

Can't get RDoc to suppress cross-references for a specific word

I'm using the jeweler gem when developing new gems. As part of the skeleton, it sets up a set of RDoc related rake tasks - the main one being rake rdoc. As far as I can tell from the Rakefile, this task uses the rake/rdoctask library to generate HTML documentation from my RDoc comments. It tries intelligently to make references to class...

What's the difference between these conditions?

Is there any specific difference between these conditions? 1) begin acct = 1 return 0 end unless self.l_acct.nil? 2) unless self.l_acct.nil? acct = 1 return 0 end ...

having problems installing ruby gem "bluepill" on ubuntu

i install bluepill on ubuntu: Linux auto 2.6.31-14-server #48-Ubuntu SMP Fri Oct 16 15:07:34 UTC 2009 x86_64 GNU/Linux Actual Result: root@auto:/# gem install bluepill Successfully installed bluepill-0.0.43 1 gem installed Installing ri documentation for bluepill-0.0.43... Installing RDoc documentation for bluepill-0.0.43... root@aut...

Make a Time.local object which incorporates a Date object in Ruby

Hi so in ruby im trying to make a program that takes an argument and returns the date exactly "x" number of months ago, I got it to say the year month and date but couldn't get it to display the hours minutes and seconds. any suggestions? Thanks require "Time" require "Date" class "Time" def months_ago(n) y = Time.now.year d = Time.now....

Rails 3, Custom Actions, and HTML request methods

I don't really understand the pro's and con's of using "post" vs "get" vs "put" requests, on custom controller actions, and whether to use links or forms/buttons. So let's say I have a simple to-do list with tasks, and a tasks controller, and I want a "complete" action where I find a specific task in the db and update it's status attri...

Bundler: Trace and check dependencies in bundled ruby gems

Bundler will automatically install any dependencies for the specified gems, it doesn't however output which dependencies map to which gems in the standard output. That information is useful when one of the dependencies fails the installation. Is there a way to set bundler to be more verbose and inform about the dependencies while instal...

How is it that find_by_id, etc. work on an ActiveRecord array?

Forgive me if I've got my terminology wrong; I am still quite new to Ruby and Rails. For school I am working on an RoR project as part of a team. I was pair programming with a teammate, who actually happens to be experienced in RoR; and I wrote something like the following: d = self.deliverables.find_all_by_lifecycle_id(self.lifecycle_...

RDoc Syntax Reference

I'm looking for a good, solid reference for proper RDoc syntax. Recommendations? I can't seem to find anything that clearly shows: How to document class methods and their parameters How to document what a class or class method does. Update 1 I found a similar question with a great answer and I wanted to reference it here: http://sta...

How can I check for undefined method for nilClass before I error out?

I am currently using the following: 20: <p>Status: <%= @contact.try(:status) unless @contact.nil? || @contac t.status.nil?%></p> However, I still get the following error: ActionView::TemplateError (undefined method `status' for nil:NilClass) on line # 20 of app/views/contacts/show.html.erb: Is there a better way to be check...

Is there an elegant way to test if one instance method is an alias for another?

In a unit test I need to test whether alias methods defined by alias_method have been properly defined. I could simply use the same tests on the aliases used for their originals, but I'm wondering whether there's a more definitive or efficient solution. For instance, is there a way to 1) dereference a method alias and return its original...