Just to clear the air, I am not some cruel factory master trying to silence working ladies. I am having a very annoying problem where when using Thoughtbot's factory girl in my specs, every time Factory.create(:foo) is used, the newly created ActiveRecord model instance is logged to the console. This makes looking at my console output ...
All i want to do is display my joined tables user and products to a view.
my code in site controller looks like this:
def receive_drop
@user = User.find_by_id(session[:user_id])
@user.product << @product1
render products_users.find(:all)
end
i should probably because of the specific nature of receive_drop, have to save pro...
In my rails project, I have a query which finds the 10 most recent contests and orders by their associated poll dates:
@contests = Contest.find(
:all,
:limit => "10",
:include => :polls,
:order => "polls.start_date DESC" )
Currently this shows each contest and then iterates through associated polls sorting the master list by poll s...
I'm just doing some University related Diffie Hellmann exercises and tried to use ruby for it.
Sadly, ruby doesn't seem to be able to deal with large exponents:
warning: in a**b, b may be too big
NaN
[...]
Is there any way arround it? (e.g. a special math class or something along that line?)
p.s. here is the code in question...
I was having a really odd problem in my cucumber tests that was causing scenarios that were passing individually, to fail when run with others in a feature. I deduced this was a MySQL related issue and sure enough, a co-worker came along and recommended I change my connection pool to a higher value in my database config. Lo' and behold, ...
Hello there,
I installed the ruby gem Daemons. To make sure it was working I created a script that would print to a file every 5 seconds. I then created another file to run the script using the trivial example they give you in the readme located at http://daemons.rubyforge.org/ . I require both rubygems and daemons. Then I type 'rub...
I encountered a problem when trying to test a module with Test::Unit. What I used to do is this:
my_module.rb:
class MyModule
def my_func
5 # return some value
end
end
test_my_module.rb:
require 'test/unit'
require 'my_module'
class TestMyModule < Unit::Test::TestCase
include MyModule
def test_my_func
assert_equal(...
I am trying to use ruby-debug to debug my specs. When i do this, i am not able to access local variables. Instance variables, however, are fine. Is there a way to make this work with local variables?
Here is an example spec:
require 'spec/autorun'
describe "empty spec" do
it "should be able to be debugged" do
x = 'foo'
@x = '...
I am trying to figure out how to add search to my rails application. I am brand new so go slow. I have created a blog and done quite a bit of customizing including adding some AJAX, pretty proud of myself so far. I am having trouble finding any good tutorials about how to add this functionality. Basically I just want to enable a full sea...
I have a an object that I'd like to grab the contents of in java.
The only problem is that is is currently in ruby.
irb(main):050:0> blah
=> "BAh7ByIeYXV0aGVudGljYXRpb25fc3RyYXRlZ2llczAiCXVzZXJpBg%253D%253D-\
-0cdecf4edfaa5cbe4693c9fb83b204c1256a54a6"
irb(main):049:0> Marshal.load(Base64.decode64(blah))
=> {"authentication_strategies"=...
Hi
I'm getting an odd LocalJumpError which only occurs when I'm in staging or production on Ubuntu. When I'm in development environment and passing the same data to the method, I don't get the error. The error is being returned when I attempt to pass data to the following method:
def standard_deviation_percentage(population)
retu...
Let's say that I was writing a closed sourced commercial piece of software which was to be deployed in the following situations: Windows Desktop App built on .Net, ActiveX control, Windows Netscape plugin, Mac Desktop App built on Cocoa, Mac Netscape plugin, Java applet hosted in browser. Would it be viable in terms of code sharing to wr...
hello i have:
ActiveRecord::Base.connection.execute "UPDATE ventas SET costo_de_compra = #{@nuevo_costo} WHERE id = #{@vid};"
but this updates that column value every time it's recursed, what i want is just to insert that value to the already stablished values in that column... in proper instance i want to add the values to an intege...
Hello,
I'm a Notepad++ user.
One of the features I like from that software is the fact that you can have a "console" in the UI (which is not an actual terminal), and that you can run some command line interpreters from there.
FYI, to get the console running in Notepad++, you need to have the NppExec plugin installed, and then go to Men...
Hello everyone i have
Class Product
has_many :sales
end
Class Sale
belongs_to :product
end
How do i get the most sold products.. (Product find all.. order by .. ventas..) ?
...
Hi,
I started using ruby-electric-mode. I like it except that I am used to closing open brackets myself (the other pairing are still useful to me). How can I make emacs suppress additional brackets when I type in the closing brackets myself? I now am manually deleting the auto-magically inserted bracket every time.
Thanks in advance...
I am working on a system which needs to keep constant (and I mean constant) track of browser side changes to a textarea via AJAX requests to the server. Ideally, every character would be stored as a row in the database, along with the position it was inserted and a timestamp.
I am hoping that there is either a good Javascript library th...
EDIT: this post only applies to Ruby 1.9
Hi,
At the toplevel method definition should result in private methods on Object, and tests seem to bear this out:
def hello; "hello world"; end
Object.private_instance_methods.include?(:hello) #=> true
Object.new.send(:hello) #=> "hello world"
However, the following also works (at toplevel)...
I have some problem with replace string in Ruby.
My Original string : What the human does is not like what animal does.
I want to replace to: ==What== the human does is not like ==what== animal does.
I face the problem of case sensitive when using gsub. (eg. What , what) I want to keep original text.
any solution?
...
Hi, I am looking for a simple way to implement simple "coming soon" (pre-launch) page for my project on Ruby on Rails.
User should be able to leave an email in order to be notified when project is launched.
Is there such a plugin\gem? Or I should do it myself...
...