Displaying 20 results from an estimated 1000 matches similar to: "Fast way of finding new position for model object?"
2006 Mar 24
6
Should counter_cache fields be saved in the database?
As far as I can tell, the counter_cache option on a belongs_to model
doesn''t actually save anything in the database. For example, I have
the following models:
class Parent < ActiveRecord::Base
has_many :children,
:conditions => "deleted_at IS NULL"
end
class Child < ActiveRecord::Base
belongs_to :parent, :counter_cache => true
end
With the following
2006 Feb 28
6
Problem with select and each_with_index
Disclaimer: Ruby newbie at work
Thought I was going so well. Wanted to produce a select box from an
array constant, with the indices returned as values , and the array
values used as the descriptions. Checked out Ruby RDoc and saw there was
an each_with_index method and came up with:
<%= select (''type'', ''typecategory'', Typecategory.each_with_index
2006 May 12
1
each_with_index. Can you start at a desired index position?
When using array.each_with_index how do you start at a desired index
position?
I can do it like this, but its not very clean and doesnt seem efficient
:
desired_index_start = 20
array.each_with_index do |value,index|
next if index<desired_index_start
end
Thanks
Chris
--
Posted via http://www.ruby-forum.com/.
2006 Apr 19
2
Ferret EOFError creating index
I''ve been messing around with Ferret (no punn intended). After spending
some time testing it out (indexing to file), I decided to index about
10% of the data I want to eventually index. It took several hours to
complete the index on my local machine, but it was created without any
problems and after optimising it the searches returned results at the
sort of speed I was expecting. I
2006 Jan 02
3
Re: Getting Index When Using render :partial (Benjamin Stiglitz)
Thanks for the suggestion, Ben. This seems an excellent approach to
the problem, except that I''d been under the impression that one could
only call render once. If you call it multiple times as the
each_with_index loop iterates, are the results just combined
automatically? How does that work?
Thanks!
Sean
-----
Sean McMains
AIM: SeanMcTex
http://www.mcmains.net/ruminations
On
2008 Jan 18
1
Values broken converting from rails into javascript
I have a section of javascript which i''m trying to use to dynamically
generate the options for a mult-select box, when another box''s contents
are changed. Basically i have a method that returns an array of arrays,
where each array is of the form
[name, number]
I then iterate over the arrays, and substitute in the values out of the
array -
2008 May 21
2
Schedule write errors?
My BackgrounDRb server intermittently bails out with the following exception
in the middle of a long running task running on a Worker sub classed
from BackgrounDRb::MetaWorker (the point at which it raises this exception
is different each time it runs)
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.5/lib/packet/packet_core.rb:145:in
`schedule_write'': You have a nil object when you
2009 Apr 30
1
error with test:functionals
Hello there,
I working on my tests but I getting this strange errror:
I can see on the database that the object was created but I still got
an failure on my test.
this is my test code:
test "should create artist" do
assert_difference(''Artist.count'', difference = 1) do
post :create, :artist => { }
end
assert_redirected_to
2006 Jan 02
2
Getting Index When Using render :partial
I''m using a web service to retrieve an array of results to a search
and a render :partial to display those results to the user, while at
the same time putting the results into the session. Is there a way
for my _book.rhtml file to have access to the index of the result
currently being displayed, like each_with_index makes available to
its block? This would allow me to have the
2009 Jul 16
9
Please help me understand how arrays are translated in rails
I''ve spent hours researching the subject and have tried many test
sequences in IRB, and rails console but I''m just having trouble making
headway into what is probably a very easy subject.
I understand arrays with at least 4 other languages but with Ruby I
haven''t found a mental connection with how I can assign variables to
arrays..
Take for example:
def
2011 Dec 07
4
what is "private method `split' called for nil:NilClass" error??
Dear all,
I have this line:
<% $c_repo.split('','').each_with_index do |repo, i| %>
in one of my template files and on the target node I''m getting this
error:
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Failed to parse template zmfs/zmfs_prob.erb: private method
`split'' called for nil:NilClass
Any idea what am I missing?
2011 Jan 27
1
performance question
I got sidetracked while benchmarking ruby factorial code:
http://rosettacode.org/wiki/Factorial#Ruby
I put all that code into test_fact.rb and ran with:
> ruby test_fact.rb
> rails runner test_fact.rb #from a fresh rails app
> rails runner test_fact.rb #from a mature rails app
here are the respective results:
user system total real #ruby
recursive:
2006 Mar 12
2
Find all the methods on a object in an irb session?
How can I find all the methods on an object from withing irb?
Thanks,
Joe
2007 Feb 28
3
[ win32utils-Bugs-8942 ] several typo in windows-pr.
Bugs item #8942, was opened at 2007-02-28 23:59
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=411&aid=8942&group_id=85
Category: windows-pr
Group: Code
Status: Open
Resolution: None
Priority: 3
Submitted By: Katsuyuki MIYAMUKO (miyamuko)
Assigned to: Nobody (None)
Summary: several typo in windows-pr.
Initial Comment:
I found typo in windows-pr.
Attached
2006 Apr 14
2
spot the error (I can''t, I''m new)
I have a form that I want to use to update multiple
objects. In the controller,
@grades = Grade.find(params[:grade].keys)
@grades.each_with_index do |grade, i|
grade.update_attribute(params[:grade][i])
end
all_valid = @grades.inject(true) {|memo, c|
c.valid? && memo }
this doesn''t update the attributes as I would expect.
(I would just use
2006 May 09
6
To Do list project?
I''m looking for a good web-based to do list app. Essentially, I''d like
to use Basecamp''s todo management system, but that''s not an option
since I can''t install Basecamp on a server I own. The information
being tracked in the list cannot be sent out of my intranet.
I would imagine that there are a couple of open source rails apps that
would meet my
2006 Nov 07
2
start a worker when bdrb starts
I am sure..again I am missing something, but I am trying to start a
worker, when backgroundrb starts and it doesn''t seem to work.
Here is my config/backgroundrb_schedules.yml file:
feed_worker:
class: feed_worker
job_key: feed_worker_key
worker_method: do_work
trigger_args:
repeat_interval: 20.minutes
I even tried this from Rails controller:
# def start_feed_worker
#
2013 Jan 30
2
Installing fog -0.7.2 for CloudProvisioner
Hi,
I am trying to install fog which is required for cloud provisioner.
> gem install fog -v 0.7.2
I am getting the following error
Building native extensions. This could take a while...
................
ERROR: Error installing fog:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make
2012 Sep 01
4
Basic Paypal
Hi all i am following this like for basic paypal
http://railscasts.com/episodes/141-paypal-basics
and i got this error
View:
<%= link_to "Checkout", @cart.paypal_url() %>
undefined method `paypal_url'' for nil:NilClass
despite i have this code in my model called Card
Cart Model:
class Cart < ActiveRecord::Base
def paypal_url(return_url)
values = {
2011 Mar 22
3
Premature end of script headers
after moving my app to production, I am getting the following error in the
apache error log. I am running on linode with apache and passenger.
any help would be great,
thanks,
Jason
[Tue Mar 22 00:18:04 2011] [error] [client 50.9.211.207] Premature end of
script headers:
[ pid=23638 thr=3063581552 file=ext/apache2/Hooks.cpp:821 time=2011-03-22
00:18:04.735 ]: The backend application (process