Is it possible for an rspec method to get the value of the parameter passed to it() in the local method? For example, if I want:
describe Me do
it "should figure this out"
puts "I " + SPEC_NAME
end
end
to print this:
I should figure this out
... what would I put for SPEC_NAME in the code sample?
Even better, how w...
I just installed the gem for will_paginate and it says that it was installed successfully. I followed all the instructions listed with the plugin and I am getting an 'undefined method `paginate' for' error. Can't find much in the way of Google search and haven't been able to fix it myself (obviously). Here is the code:
PostsController
...
I'm using Ym4r and want to add a polyline to my map.
This works:
polyline = GPolyline.new([[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]],"#ff0000",3,1.0)
@map.record_init @map.add_overlay(polyline)
But this doesn't:
polystring = "[27.4037755983,89.4263076782],[27.5155793659,89.3245124817]"
polyline = GPolyline.new([po...
I've been searching on how to solve this issue but could not find any real and working solution.
User model:
validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/gif']
Unnecessary error shows up when invalid file type is uploaded:
Avatar /tmp/sample,23283,0.txt ...
Hi,
I was wondering if there is a similar .finalize() method for Ruby objects, that marks them ready for garbage collection. If I would create 20,000 objects and each instance has a counter, I would like the object to be marked for garbage collection when reaches zero. I know this is pretty much a Java approach, but I have not sufficien...
How do I setup a Gem to have a binary command eg. "project newProject" that uses Thor's set of generator commands to create files etc.?
A good answer would describe how to layout the skeleton of a gem that that when run from the command line "project newProject" creates 1 file named "newProject.txt" in the directory it's run from.
I've...
I'm building an app that uses subdomains as account handles (myaccount.domain.com) and I have my sessions configured to work across the sub-domains like so:
config.action_controller.session = {:domain => '.domain.com'}
In addition to the subdomain a user can input a real domain name when they are creating their account. My Nginx conf...
Yesterday I tried to install Jeweler via Rubygems, however somewhere in the middle of the process I had a power failure, resulting in my computer turning off in the middle of the installation process.
Once I got it back up, I tried to reinstall Jeweler, however resulting in an error I've had trouble decoding.
Does anyone have any ide...
I'm implementing a small HTTP server with Ruby using Mongrel. My code currently looks like this:
require 'mongrel.rb'
class SimpleHandler < Mongrel::HttpHandler
def process(request, response)
puts request.body # outputs #<StringIO:0xb7656e74>
response.start(200) do |head,out|
head["Content-Type"] = "application/ocsp-re...
Is there any way to do this? It seems the only possible way to do this is by using ruby/tk and creating a tcl interpreter through that api. However, I'd like to use this on a system with no GUI (x windows). Am I out of options?
Thanks
...
Unfortunately, GAE requires restart of the server on each code change.
Is it possible to prevent it and have immediate feedback after code save?
Or, can I import Google App Engine's API into my ruby code and run it on Sinatra server? Tried this but it fails on "import com.google.appengine.api" (it doesn't know what 'com' is).
For Sinat...
Although it’s probably meant to be experienced on the web, I’d love to read a great print version of Why’s Poignant Guide to Ruby.
It’s liberally licensed, so I can run off a copy for myself. But I think a work like that deserves more. Full colour illustrations. Main text on the left-hand page, sidebars on the right. (Stick in a few car...
Given the code below, how could I use the I18n lib to get the result back in an other language than English?
require 'action_view'
include ActionView::Helpers::DateHelper
t_0 = Time.now
span = 1.week
puts "Now: #{ t_0 } (#{t_0.to_f})"
puts distance_of_time_in_words_to_now Time.at( t_0 + rand( span ) )
...
does anyone know if it is possible to do a double nested form for. so that i could upload images to a set from an article form.
e.g.
Article
has_many :image_sets
ImageSet
belongs_to :article
has_many :images
Image
belongs_to :image_set
...
Hi,
Programming is fun: I learned that by trying out simple challenges, reading up some books and following some tutorials. I am able to grasp the concepts of writing with OO (I do so in Ruby), and write a bit of code myself. What bugs me though is that I feel I'm re-inventing the wheel: I haven't followed an education or found a book ...
I have built a blog application using Ruby on Rails. In the application I have posts and tags. Post has_many :tags and Tag belongs_to :post.
In the /views/posts/index.html view I want to display two things. First is a listing of all posts displayed 'created_at DESC' and then in the side bar I am wanting to reference my Tags table, grou...
I manage a research database with Ruby on Rails. The data that is entered is primarily used by scientists who prefer to have all the relevant information for a study in one single massive table for use in their statistics software of choice. I'm currently presenting it as CSV, as it's very straightforward to do and compatible with the ...
For some reason when an object's instance has errors, the f.label tags associated with error attributes isn't wrapped about the field_error_proc.
Is this the default behaviour?
...
On Ruby 1.8.7 a fresh Rails 2.3.5 environment loads in 4.325 seconds, but on Ruby 1.9.1p378
it takes 15.701s - does anyone have any ideas why?
This is on a 32-bit single core laptop running Ubuntu.
...
I'm using Mirven's Twitter OAuth Sinatra example and trying to figure out how I can send a 'next page' parameter with the Oauth request:
ie. The user attempts to visit /edit/profile which requires a login so I redirect to /request which deals with login via twitter - I now want to be able to redirect the user to the address they were or...