ruby

How do you call Win7 Taskbar API via Ruby Win32API module?

I am writing plugins for Google SketchUp using their Ruby API. One of the common problems we (SketchUp scripters) have is that when a script is performing intensive operations it locks up the SketchUp UI and there is no way to see the progress of the current process. What I would like to do is call the new Taskbar API in Windows7 in a h...

Iterate over a array and returning the next and the element before current.

How may i fetch next and before current element from array while iterating array with each. array.each do |a| # I want to fetch next and before current element. end ...

Can I send instance variables to Tequila (.jazz) JSON Parser? (Ruby on Rails)

I am using the great Tequila-JSON Parser ( http://github.com/inem/tequila ) in an Web-application, to render more or less complex JSON server-replies. More and more the JSON-Templates (.jazz) are growing in somehow real "views". I am trying now, to get an instance-variable from the according controller, into the .jazz template, but this ...

How To Display Characters Received Via A Socket?

I have a very simple Ruby program that acts as an "echo server". When you connect to it via telnet any text you type is echoed back. That part is working. If I add a 'putc' statement to also print each received character on the console running the program only the very first character displayed is printed. After that it continues to echo...

What's the Rails way to mirror an LDAP directory as a SQL table?

So I'm creating a Rails app that will function as a directory for contact information in our organization. But it's not as simple as it sounds. We have a large LDAP-enabled directory which contains information for all of the users in our organization of tens of thousands. We have a smaller, separate LDAP-enabled directory which contain...

Ruby (MRI) Syntax Tree nodes documentation

The meaning of most nodes from mri's syntax tree can be easily infered. However the list is quite long (source: bin/parse_tree_abc): :attrasgn, :attrset, :dasgn_curr, :iasgn, :lasgn, :masgn, :and, :case, :else, :if, :iter, :or, :rescue, :until, :when, :while, :call, :fcall, :super, :vcall, :yield, :args, :argscat, :array, :begin, :block...

how to remove the " quote from string?

This is my string: msgid """We couldn't set up that account, sorry. Please try again, or contact an ""admin (link is above)." I want to remove all the double quotes except the first and last one. How may I do that? ...

In Ruby, should we always use "&&", "||" instead of "and", "or" unless for special situations?

Is it true that in most cases, in Ruby, it is best to use &&, || instead of and, or, unless it is some special situations. I think one of Ruby's design principles is to have least surprises as possible, so using and, or or actually have some surprises... such as and not having a higher precedence than or, while && has a higher precedenc...

About Ruby error 'kEnd' ?

I'm having a lot of trouble with Ruby after coming back to it from a long break. I'm getting a lot of 'unexpected kEND' errors, and I've tracked it down to lines below. I'm not having trouble with a particular piece of code, but rather, the concept of 'unexpected kEND' . if (condition) do-one-line-thing() and # inside of a loop....

ruby on rails custom setter help

Hello, sorry for my english, I have a model named Recipe and Recipe has an attribute named duration In my form, I have 2 dropdowns to get duration attribute select_tag 'duration[hours]' select_tag 'duration[minutes]' I need the value of duration attribute like this format hh:mm:ss I have tried with def duration=(d) self.duration...

Playing with Scrapi in Rails 3.. getting Segmentation Fault error / Abort Trap

What I've done so far.. sudo gem install scrapi sudo gem install tidy This didn't work because it didn't have the libtidy.dylib So I did this : sudo port install tidy sudo cp libtidy.dylib /Library/Ruby/Gems/1.8/gems/scrapi-1.2.0/lib/tidy/libtidy.dylib Then I started following the simple railscast at : http://media.railscasts.co...

rails console - display active record results in a table

Is there a way to display Active Record results in table format in the script/console environment? ...

Ruby Telnet Login Problem

Hello, I am having problems with Ruby Telnet API. More specifically, the login command. My code is as follows: options["Name"] ||= 'anonymous' options["Password"] ||= '******' @connection.login( options, &block ) And the output... Trying 10.160.52.63... Connected to 10.160.52.63. login: a ...and then I get a T...

Update a String Attribute in Rails

I am trying to update a string attribute in the database. I tried using update_attribute but it isn't working. It works for integer attributes but not for String attributes. How do i solve this ? EDIT code example: @post = Post.find(params[:post_id]) @comment = @post.comments.create!(params[:comment]) @comment.update_attribute(:comm...

Gem dependency issues

Let us say there are two gems A ( depends on gem C version 2) B ( depends on gem C version 1) My rails application requires gem A, and B. How do you handle the collision of two versions of the gem C while loading A and B. ...

ruby Hash include another hash, deep check

Hi guyes, what is the best way to make such deep check: {:a => 1, :b => {:c => 2, :f => 3, :d => 4}}.include?({:b => {:c => 2, :f => 3}}) #=> true thanks ...

Devise Custom Routes and Login Pages

I'm trying to get Custom Routes working in my Rails application (Ruby 1.9.2 with Rails 3). This is my config/routes.rb file match '/dashboard' => 'home#dashboard', :as => 'user_root' devise_for :user do get "/login", :to => "devise/sessions#new" # Add a custom sign in route for user sign in get "/logout", :to => "devise/sessions#...

Need Recommendations for Twitter and Facebook Gems

Hi, I'm building an app in Rails 3. I currently have a user model which is authenticated via devise (email + password auth). I want to be able to show connect to facebook, connect to twitter buttons to the users once they are logged in. After obtaining the keys from Facebook and Twitter, I'd want to store it in the database for futur...

CSS Sprite generator for Ruby on Rails project

I'm currently working on a large, highly trafficked Ruby on Rails website and in order to get our page load times down, we are looking at spriting our background images. There seem to be a lot of tools out there but many are in the early stages of dev and many don't support some of the features we need. Features which are important to ...

How do you install Ruby on Rails plugins?

I am trying to install the has_calendar plugin, and it says that is successfully installing. However, when I have a page with code the plugin should execute, I am returned errors of undefined functions. Is there somewhere I need to reference the plugin as a helper? Here the sample code, straight off the wiki page. <%= calendar :year =...