ruby

Library and examples of accessing a privately shared Picasa Album in ruby

does anyone have any examples of accessing a private album that is shared to me (ruby preferred) ...

Error running autotest on Windows 7 with Rails 3, Ruby 1.9.2

Installing and running Rails 3 and Ruby 1.9.2 on Windows 7 went rather smooth. It's only now that I want to run autotest that I'm running into problems. The error looks frustratingly simple, but I can't figure out how to solve it. I have the following gems in my Gemfile: gem 'autotest' gem 'autotest-rails-pure' But then when I run ...

What does a * in front of a string literal do in ruby?

This code seems to create an array with a range from a to z but I don't understand what the * does. Can someone please explain? [*"a".."z"] ...

Running redcar 0.8.1 on Windows 7 x64

I am trying to get redcar to run on a windows 7 x64 box but I am getting the following error: Redcar 0.8.1 ( java ) Error loading plugin: <Plugin swt 1.0 depends:[dep(core >0)] 0 files> cannot link Java class org.eclipse.swt.widgets.Display, probable missing dependency: Cannot load 32-bit SWT libraries on 64-bit JVM c:/devtools/jrub...

Can't use flash in ActionView::TestCase when I want to test my helper class

I wanted to test a method in my helper class but when I do something like: require 'test_helper' class ApplicationHelperTest < ActionView::TestCase def test_flash_messages flash[:notice] = "Hello World" assert_equal "<div class=\"message-notice\">Hello World<\/div>", flash_messages end end than I get "NoMethodError: undef...

Changes to the code are not getting reflected in Rails 3.0

Hi, I have started a project using Rails 3.0. I am using devise for the authentication. Devise includes links to signin and forgot password in the sign up page. These links are loaded by means of a partial.I did not need these links, so I removed them and reloaded the page, but still these links remain. I tried clearing the cache and ...

Why do I keep getting this "help" error code from Wikipedia API?

Hi, I'm trying to get a random page from Wikipedia, using WikiMedia's documented Random method. Safari has no problem getting the page: http://en.wikipedia.org/w/api.php?action=query&amp;list=random&amp;rnlimit=1&amp;rnnamespace=0&amp;format=json But when I do, using Ruby HTTP/Net, I keep getting this exact error page: http://en.wikip...

ActiveRecord: change and save object state inside model

I have the following code: def incoming_acceptation(incoming_code) if invite_code == incoming_code accepted = true self.save true else false end end But it does not change and save accepted to true, it remains in the previous state, false. @i.incoming_acceptation(incoming_code) => true @i.accep...

How to split a string in Ruby?

I have special strings like name1="value1" name2='value2'. Values can contain whitespaces and are delimited by either single quotes or double quotes. Names never contain whitespaces. name/value pairs are separated by whitespaces. I want to parse them into a list of name-value pairs like this string.magic_split() => { "name1"=>"value1",...

How to bundle install a git gem behind a proxy?

I am behind a proxy and I have a git gem in my Gemfile. How can I configure bundler to use git with the appropriate proxy parameters? I already have $http_proxy appropriatelly set, as well as my .gemrc . Still, it doesn't work. ...

uninitialized constant Ckeditor::PLUGIN_CONTROLLER_PATH

I've try to use ckeditor in my apps. I followed instruction how to install it, but when I came to this step $ rails generate ckeditor:base I got this error message, uninitialized constant Ckeditor::PLUGIN_CONTROLLER_PATH, and I didn't know to solve it. Does any body know how to solve it? please. ...

3rd party applications inside iFrames?

I am about to build a web application and I want to allow other developers extend it with their own applications. Should I do this with iFrames like Facebook? Is this a good practice? Are there other alternatives that let other developers extend my application (that is for the user it looks like it's from my application). To be speci...

Rail performance on ARM

I was wondering if we could replace our Atom N270 based nettops that are running a Rails(ruby 1.8.6...) webapp with some equivalent ARM based device (we like the fanless setup, power consumption, etc.). The ARM device was XScale-PXA270 @ 520, 128MB (and probably some slower SDRAMs), running linux, there was always enough free memory wi...

Mail gem - how to clean up the body string

I'm trying to read an email using ruby mail gem. But mail.body.decoded returns me not just the body message. How can I clean up this body message and remove unwanted text like "--20cf30433c9a437cc304939017ef\nContent-Type: text/plain; charset=ISO-8859-1\nContent-" ? message = $stdin.read mail = Mail.read_from_string(message) puts mail....

How to create a "class cluster" (factory class with instances of concrete subclasses) in Ruby?

I would like to create an abstract class which will create concrete instances depending on initialization parameter. Example: class SomethingGeneric def self.new(type, arg) class_name = "#{type.capitalize}Something" if obj.const_defined?(class_name) a_class = obj.const_get(class_name) else raise ArgumentErr...

How is Ruby module inclusion not really 'multiple inheritance' and how does the Ruby style avoid the problems associated with multiple inheritance?

Matz supposedly said "mixins could do almost everything multiple inheritance do, without the associated drawbacks" (Matz words)." First of all, why is Ruby module inclusion not 'multiple inheritance' ? It seems to me there is very little difference between modules and classes. The fact you cannot instantiate a module is irrelevant when ...

Ruby syntax question: Rational(a, b) and Rational.new!(a, b)

Today I came across the strange ruby syntax in the Rational class: Rational(a,b) (Notice the absence of the .new()portion compared to the normal Ruby syntax). What does this mean, precisely, compared to the normal new syntax? More importantly, how do I implement something like this in my own code, and why would I implement something...

Best way to add "uncheck radiobuttons" - functionality in Rails ?

Scenario: I have a dropdown-list with radiobuttons, that are not required to be selected to submit the form, and after I've chosen an option, from there on it's impossible to deselect it. I want it to be possible somehow. Thoughts for solutions: 1) Implement some feature that enables you to deselect the radiobutton, much like a checkbox...

Rails Newbie: Recommendations for error handling in controller

Sorry if the question is obvious, I am only starting to work with Rails. I have a following code in several controller methods now: respond_to do |format| if @project.save format.html { redirect_to(edit_project_url(@project), :notice => '#{user.name} added to #{role}.') } format.js else format.html { rend...

Writing to an IO stream in Ruby instead of sanitizing user input and sending to the shell?

I was just reading a blog post about sanitizing user input in Ruby before sending it to the command line. The author's conclusion was: don't send user input it to the command line in the first place. In creating a contact form, he said he learned that What I should do instead is open a pipe to the mail command as an IO stream an...