I have a table that stores what users input into a search field. I wrote an action that displays the most popular searches and the number of times the search has been made. To do this I wrote the following sql query in the controller...
SELECT…
I need to serialize lots of objects to a file (multiple GBs). We have chosen to use Google's protocol buffers for other things in this project, so I thought I would use that to serialize the objects I receive from the wire. This seems to…
In Ruby 1.8.7 the following regex warning: nested repeat operator + and * was replaced with '*'.
^(\w+\.\w+)\|(\w+\.\w+)\n+*$
It does work in Ruby 2.0 though?
http://rubular.com/r/nRUSP5LNZA
In an ActiveRecord model, are there any static/canned formats I can use? For instance, when validating the format of an email address I can either make a static regex to reuse on other models or perhaps use some static that already exists in the…
What I have is:
p(array)
array.each { |c| c=c*y**z-1 ; z=z+1 }
p(array)
The array is:
[35, 35, 35]
y is 36, z is a counter, c is the value in the array.
Before the formula I get:
[35, 35, 35]
[formula happens]
After the formula:
[35, 35, 35]
My problem is that chips is not saving as a global variable for the argument it is passed. I am passing $h1c (which is the number of total chips player's first hand has). So if he wins or loses, chips should then be set equal to chips + or -…
I use ruby 1.8.7 and get the params from my form like this:
"cart"=>{"1140229"=>["5"], "1140228"=>["4"], "1140222"=>["7"]}
And, I use rails 2.3 (it's too old, I know it!) which requires this syntax:
1140229 => { :quantity => 5 }, 1140228 => {…
ive been working with rails 3 and ruby 1.8.7 and ALWAYS (in all my apps),
i have problems with the STARTUP time delay.
it sometimes loads ok, and sometimes takes more than 12 seconds (or more) just to start loading the site.
one of my…
I would like to build a rake task or a tool to destroy all active sessions that is called from CLI when I want and on every night at around 9:00 pm or so.
I found that Devise has the ability to specify a timeout. I use Devise for user sessions.…
I'm moving an old application from rails 2.3.2 to 2.3.18, ruby 1.8.7-p72 to 1.8.7-p374. (and then after that, to ruby 1.9.3 and rails 3)
My first query I tried which should be simple is giving me problems. In the console:
?> User.find(:all, :joins…
I am simply trying to get the root path to look up a file on my machine, I am pretty new to RoR. Is there some sort of variable somewhere so I could do something like this:
def path
return '{#ROOT}/some/path/file.txt'
end
I do not want the…
What I need- some kind of way to grab the number entered into the form in order to check it against previous records PRIOR to updating, so that if a validation error occurs, the user can be prompted to confirm before the form is submitted. Params…
I am trying to come up with a good way to do the following. I have a string, such as this one:
foo = "bar = everybody\nbar = say\nbar = hey\nbar = ho"
And I am scanning through it like this:
foo.scan(/^bar = (.*)$/)
That returns:
[["everybody"],…
I have an app that manages images associated with buses. My problem is that I can't figure out how to sort an each block by a particular BusImage attribute, :thumb_order instead of the BusImage id.
A Bus has many BusImages.
The instance variables…
My question is simple, I'm trying to build a system to manage Users and Groups for each User, so in order to add a user to a group (or remove the user from a group) I need to know which groups this user belongs to in both sides. Otherwise I have to…