There is a simple database in Sequel:
DB = Sequel.sqlite
DB.create_table :items do
primary_key :id
DateTime :date
String :name
end
items = DB[:items]
items.insert(:name => 'abc', :date => DateTime.now)
items.insert(:name => 'ghi', :date => DateTime.now)
items.insert(:name => 'def', :date => DateTime.now)
The question: is...
I want to limit the subprocesses count to 3. Once it hits 3 i wait until one of the processes stops and then execute a new one. I'm using Kernel.fork to start the process.
How do i get the number of running subprocesses? or is there a better way to do this?
...
Hi...I am getting undefined method [] for true:TrueClass error while running the rake task in acts_as_recommendable plugin. The error points to the following line.
items = options[:on_class].find(:all).collect(&:id)
Can someone please tell what am i doing incorrectly.
...
csv sample:
Date,128,440,1024,Mixed
6/30/2010,342,-0.26%,-0.91%,1.51%,-0.97%
6/24/2010,0.23%,0.50%,-1.34%,0.67%
i want to render this data in a multi-line graph
...
I can generate a few lines of code that will do this but I'm wondering if there's a nice clean Rubyesque way of doing this. In case I haven't been clear, what I'm looking for is an array method that will return true if given (say) [3,3,3,3,3] or ["rabbits","rabbits","rabbits"] but will return false with [1,2,3,4,5] or ["rabbits","rabbits...
I'm seeing code like this inside of an erb template:
<% hook :admin_footer_scripts do -%>
What exactly is hook? is it a standard method within ActionView?
...
in ruby you can have:
class ApplicationController < ActionController::Base
before_filter :require_login
end
i just wonder what is before_filter? it's a method from ActionController::Base?
and what will happen if i create an object of ApplicationController? The before_filter method will be run?
thanks!
...
This is a helper method I found in the ruby on rails application spree commerce.
I'm trying to better understand what's going on here, particularly with the capture() method on line 12, which I've never seen before. If there is a block given, it captures it, otherwise there is no content. But where does capture() come from? what is it d...
Hi,
I can't install ruby 1.9.1. I tried installing macports, homebrew, and RVM. I installed macports but somehow when I used the commands it didn't work. Installing homebrew was a problem in of itself. Ditto for RVM.
Can anyone provide step by step instructions on how to do this on a mac leopard.
Geez, didn't think it would be this ...
I am running Ruby 1.9.1 & rails 2.3.8. Everything is installed fine as far as I can tell but when I run rake db:migrate I get this error:
Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VE...
The code below seems to do the same thing, but does one have better performance than the other, or they are the same? Thank you.
Code 1:
<% @posts.each do |post| -%>
post.doSomething
<% end -%>
Code 2:
<% for post in @posts %>
post.doSomething
<% end -%>
...
I'm working on an API wrapper for Viddler, which will eventually be made public, and I'm trying to figure out the best way to deal with authentication/API keys, specifically with usage within Rails applications in mind.
The easiest way to write the wrapper would be to just have the code create a new client each time, and the developer c...
What version of Ruby should I be using on a windows environment?
I'm trying to use Watir on 1.9 and it does not work. Will work on 1.8.6.
Any recomendations on which version to use and reasons why Watir does not work on 1.9
...
I want to make a hook method which gets called everytime any function of a class gets called.
I have tried method_added, but it executes only once at the time of class definition,
class Base
def self.method_added(name)
p "#{name.to_s.capitalize} Method's been called!!"
end
def a
p "a called."
end
def b
p "b called...
Hi,
I am trying to consume a SOAP service using the Savon gem but having difficulty. I have accessed the SOAP service using soapUI and it works fine.
My code:
require 'rubygems'
require 'savon'
# Client instance with a WSDL endpoint
client = Savon::Client.new "http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx"
p client.wsdl.namespa...
I just started a new project yesterday and I'm having a lot of very strange transactional fixture problems. It sounds like this is something of an issue with Rails, so I'm hoping StackOverflow can help. Here's the rundown.
Coworkers can run tests fine. They are running Mac OS X; I'm running Ubuntu.
When use_transactional_fixtures is tr...
Hi
I face the error when I try to move one file from another.
I'm sure that path is correct. The platform is windows. Permission is correct.
My code is below:
unless File.exists?(f2)
FileUtils.move(f1,f2)
end
Note I don't face problem with every file.
...
I want to validate that zip code entered by user is valid or not.
for example user entered 009876654 and it is not valid then an error message should be given.
I know i can do it using javascript regulr expression or using ajax-zip-code-database
But i don't want any of the above. i need some plugin sort of thing which send request t...
I have two models, Leads and courses, Leads HABTM courses.
I want to list all courses in leads/new as checkboxes, at the moment I have them as a multiselect box, but I dont like the way it works.
This is what I have at the moment
<%= f.collection_select :course_ids, Course.find(:all, :order => 'course_type'),
:id, :course_name, {},...
I'm working through http://railstutorial.org (currently working on section 10.4.2 - destroying users).
My User model has a boolean admin attribute, and in the Users controller there is some simple code making use of this attribute:
def admin_user
redirect_to(root_path) unless current_user.admin?
end
The RSpec test:
describe "as a ...