Hello, currently I am running something similar to this command:
Person.sum(:cholesterol, :group => :age)
which seems to work great when I have a small number of records. However when I attempt to call this with a few thousand records or more in the table, it takes literally minutes to run. However, the SQL querey:
SELECT sum(`peopl...
I am pondering on using a Restful implementation in Rails. I'm asking myself if it's the way to go.
Should I always go for a Restful implementation or not?
...
I have a engine style Rails plugin from which I can create a gem using Jeweler. But when I require it in my Rails environment (or erb) the models within the plugin are not loaded. I have followed a number of tutorials and read just about everything on the subject.
# environment.rb
config.gem 'myengine'
# in irb
require 'myengine'
I ...
I've added 2000 pictures to my images table and I'm using the Paperclip plugin to create thumbs. I'm wondering if there's a way to go through the database and add another :styles element.
For example, when I added the images I had the following in my model:
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x10...
With these associations only the magnification results returns the correct results, but when I try and search for the second association it will return 0 results.
has_one :magnification,
:class_name => 'ProductAttribute',
:foreign_key => 'product_id',
:conditions => {:key => 'Magnification'}
has_one :objective_lens,
:class_name ...
If I have only the information in Simply Rails 2 now and I want to create more complicated apps next, what should I do to learn that?
...
I have a form_remote working perfectly for the form currency. The only change I want to make is the do away with submit button for a select box. So they just click the correct currency and it submits the ajax request.
<%= collection_select(:currency, :set, Currency.find(:all, :conditions => 'primary_source = "ECB"'), :code, :pretty_na...
Hello community,
I'm learning to program with Ruby on Rails and I've reached my hardest task yet. I have two tables, each containing a list of business categories (I.E. Thai Food Restaurant, Plumber, Office Supply Store). These two tables come from two different APIs where I'm essentially acting as the middle-man between them. They list...
I'm using Prawn and Prawnto to generate a PDF in a Ruby on Rails app (Rails version 2.2.2) which works great and generates PDFs happily and sends them to the user to download in Firefox.
The problem is in IE7.
I have a route set up like so:
map.invoice_pdf '/invoices.pdf', :controller => 'invoices',
:action => 'inde...
Our Rails app has some views that get heavy traffic but don't change too often (weekly at the most). I want to cache these views but we use subdomains to specify user accounts.
I've seen a few different blog posts on how to cache views based on subdomains. Just wondering what the preferred method is.
Also, one of the pages we need to ...
From The Ruby Way:
This book is largely intended to answer questions of the form of "How do I…?" As such, you can expect to do a lot of skipping around. I'd be honored if everyone read every page from front to back, but I don't expect that. It's more my expectation that you will browse the table of contents in search of techniques you n...
Hi Group,
I have a Ruby on Rails (Rails v2.0.2) application which I have developed using Netbeans 6.1 on Mac OS X.
When I tried to run this application this evening (it was working fine this morning) I get the error:
'could not connect to the web server - cannot show http://localhost:3000'
When I try to run the application from termi...
I have a script that I want to loop indefinitely outside my rails app, essentially it's just writing values over serial (with the SerialPort library), Can I just us backticks to run my script?
Lastly my biggest concern is that the script will block requests to my rails app while its running. I want it to spawn it's own process, is this...
I'm attempting to use the new standard way of loading seed data in Rails 2.3.4+, the db:seed rake task.
I'm loading constant data, which is required for my application to really function correctly.
What's the best way to get the db:seed task to run before the tests, so the data is pre-populated?
...
I've had problems with autotest before which I resolved by downgrading from ZenTest 4.1.4 to 4.1.3.
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ rails -v
Rails 2.3.4
Currently I'm finding that on my Mac OS 10.6.1 Snow Leopard system, when I run $ autotest in my project no tests are run and I get this output...
Anyone have this happen before? I just uploaded my app to a staging server that's identical to the production server. I try to log in, and I get the "Something went wrong" 500 page. The log tells me the error is in my SessionsController (using restful_authentication), with the specific error being NoMethodError (undefined method 'enab...
Is it possible to refer to ruby class variables in a view?
...
I want to learn a framework that promotes good programming practices and is respected by the programming community.
However, I also want a framework that I can use for a day job.
Which one would you recommend?
This question comes from my experience of learning the basics of Django because it was highly acclaimed by developers on Stack...
I want to create one form with 2 buttons in rails. Both forms operate on the same data in different ways, and I would prefer to keep the associated functionality in two different methods. Previously I've redirected to the appropriate method after doing a string comparision on params[:commit], but my gut says there's a better approach. Su...
I do my Rails dev from xterm and in vim.
I'm getting sick of running script/generate migration do_whatever, then trawling through db/migrate trying to tab-complete to 20091015235018_do_whatever when there's 5 other migrations with similar timestamps.
What's the best way to add a hook to open the generated migration in vim?
I'd rather ...