I posted a question awhile ago asking how I could limit the rate at which a form could be submitted from a rails application. I was helped by a very patient user and their solution works great. The code was for my comments controller, and now I find myself wanting to add this functionality to another controller, my Messages controller. I...
It seems to me that the Ruby community has been freaking out a little about autoload since this famous thread, discouraging its use for thread safety reasons.
Does anyone know if this is no longer an issue in Ruby 1.9.1 or 1.9.2? I've seen a bit of talk about wrapping requires in mutexes and such, but the 1.9 changelogs (or at least as...
I've been banging my head against the wall for the better part of an hour trying to figure out what's going wrong here, and I'm sure (or rather hoping) it's something fairly obvious that I'm overlooking. I'm using Ruby 1.9.1, Sinatra 1.0, and RMagick 2.13.1. ImageMagick and RMagick are correctly installed and functional—I've successfully...
So all I simply want to do is make a Ruby program that reads some values from known memory address in another process's virtual memory. Through my research and basic knowledge of hex editing a running process's x86 assembly in memory, I have found the base address and offsets for the values in memory I want. I do not want to change the...
Ok, so I was comparing some stuff in my own DSL to Ruby. One construct they both support is this
x=["key" => "value"]
Knowing the difference between arrays and hashes, I would think this to be illegal, but the result in Ruby is
[{"key" => "value"}]
Why is this? And with this kinda syntax why can't you do
x=("key" => "value")
Wh...
I have developed an application and I seem to be having some problems with my associations. I have the following:
class User < ActiveRecord::Base
acts_as_authentic
has_many :questions, :dependent => :destroy
has_many :sites , :dependent => :destroy
end
Questions
class Question < ActiveRecord::Base
has_many :sites, :dependent...
I think I am missing something while using the Authlogic gem w/ Rails. To set the stage I have multiple users and each user can create posts and comments. Upon the display of a post or comment I would like to give the user who created them the option to edit or destroy.
I am successfully using the following code to hide and show element...
Sorry if the title is not enough to understand what i am asking about.
I am rails developer and i used multiple lines of <% %> in my views but now i realized that it's not best practice so i came here and like to you all excellent guys what is the correct way in ROR?
For example if i required to something like following
<% user =User....
Hi all
I am getting this problem when I run this code in server. In my localhost everything is running fine. But when I deploy my code in the server it shows me the error.
I am using FERRET SERARCH IN MODEL.
NameError in CompetitorsController#index
uninitialized constant CompetitorsController::Competitor
/opt/ruby_enterprise/lib/rub...
Hello,
I am receiving the error:
uninitialized constant SQLite3::Driver::Native::Driver::API
within my application, however I have installed:
ctionmailer-2.3.5
activerecord-jdbcsqlite3-adapter-0.9.6-java
jruby-openssl-0.6
rails-2.3.5
actionpack-2.3.5
activeresource-2.3.5
mysql-2.8.1
sqlite3-ruby-1.2.5
activerecord-2.3.5
activesuppor...
I've looked quite a bit, but I haven't been able to find a good programmatic way to list the queues on a RabbitMQ server.
This is important because I need to clean up my queues and exchanges when I'm done with them. I don't always have a good "done" event that can be used to trigger a cleanup, so I'd like to do it with more of a garbag...
Hi all
I am getting this error when I am using
acts_as_ferret :fields =>[:competitor], :remote => true
NameError in PartController#index
uninitialized constant PartController::Competitor
My Model
class Competitor < ActiveRecord::Base
validates_presence_of :fee_earner_id, :notes
belongs_to :fee_earner
belongs_to :country
be...
Hello everyone,
I am new to Linux. And I am using Red Hat Enterprise Version 5. There is a ruby program which use standard input as its input (e.g. the Ruby program process input from standard input). I think standard input should be keyboard, correct?
So, I think other kinds of input (non-standard input) should not work (i.e. the ruby...
I'm trying to recreate a race condition in a test, so I can try out some solutions. I find that in the threads I create in my test, ActiveRecord always returns 0 for counts and nil for finds. For example, with 3 rows in the table "foos":
it "whatever" do
puts Foo.count
5.times do
Thread.new do
puts Foo.count
...
I have a class like this:
class Router :: Mongrel::HttpHandler
def process(req, res)
status, header, body = [200, {"Content-type"=>"text/html"}, Model.all.to_xml]
res.start(status) do |head, out|
header.each_pair { |key, value| head[key] = value }
out.write body
end
end
end
It's an server and I use...
My Problem: I am trying to developing a web application for currency traders. The application allows traders to enter or upload information about their trades and I want to calculate a wide variety of statistics based on what the user entered.
Now, normally I would use a relational database for this, but I have two requirements that...
Hi,
I am trying to setup an ror app but I keep getting this error. Any ideas as to what may be causing the problem?
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support...
I would like to do is to know if a user has been created in the system in the last 10 second.
so i would do:
def new_user
if(DateTime.now - User.created_at < 10)
return true
else
return false
end
end
IT is just an idea , how can i do it correctly?
thank you
...
i would like to write a message using an instince variable in the new invition action like this. redirect_to new_invitation_path("invite your friend")
Controller invitations:
def new(message)
@message = message
@from_user_id = facebook_session.user.to_s
end
Apparently it is not possible how can i find a way around this?
...
a = WWW::Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
agent.history.max_size=0
}
page = a.get('http://livingsocial.com/deals?preferred_city=18')
Trying a very basic GET request using mechanize but get a 500, yet when I CURL I have no problems. Is there a problem with including parameters in a get() call? ...