I currently have a Postgres DB filled with approx. 300.000 data-sets of moving vehicles all over the world. My very frequently repeated query is: Give me all vehicles in a 5/10/20mile radius. Currently I spend around 600 to 1200 ms in the DB to prepare the set of located vehicle-objects.
I am looking to vastly improve this time by ideal...
class student < ActiveRecord::Base
has_many :projects
def has_a_teacher_by_the_name_of(name)
self.projects.any? { |project| project.teacher.exists?(:name => name) }
end
end
class project < ActiveRecord::Base
belongs_to :student
has_one :teacher
end
class teacher < ActiveRecord::Base
belongs_to :project
end
This does...
I was wondering if there were any suggestions for how to best roll with full text searching in your Rails 3 apps? Thinking Sphinx and acts_as_ferret aren't updated for Rails 3 yet, and even basic activerecord search helpers like Searchlogic also aren't there yet.
Any thoughts? Are you using any forked versions of the above gems that ha...
Hy,
I have:
@layout = [:maincol => ['a'], :sidecol => []]
then i want to loop and get
<div class="maincol"><div class="a"></a></div>
<div class="sidecol"></div>
how to do it?
...
I have a worker process that is running in a server with no web frontend. what is the best way to set up monitoring fot it? It recently died for 3 days, and i did not know about it
...
I want alternative rows in my table to be shaded. what is the best way to do this, javascript, rails?
Today, i do a simple <% num % 2%>, but this is such a common operation that i think there should be a smarter way to do it
...
I want the /admin route on my rails app to be protected by using .htaccess password files - is this possible?
...
Hello all,
I'm working with a rails app which plays mp3s. Is there a way to catch the request for the mp3 file with ruby, reformat the request(url), and pass the request along?
I'm really just trying to protect the urls...
...
Is it true that HABTM relationship does not support :dependent option.
class Person < ActiveRecord::Base
has_and_belongs_to_many :posts, :dependent => :destroy
end
I am trying rails edge.
...
We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model.
On the same line, do we have a script/generate for changing the datatype of a column? Or should I write sql directly into my vanilla migration?
I want to change a column from datetime to date.
Thanks
...
Hello. I got a 500 Internal Sever error when I try to deploy my rails app on heroku. It works fine on my local machine, so i'm not sure what's wrong here. Seems to be something with the "sessions" on the home controller. Here is my log:
==> production.log <==
# Logfile created on Sun May 09 17:35:59 -0700 2010
Processing HomeContro...
I am trying to set up a blog using Enki. There is a config file here: http://github.com/xaviershay/enki/blob/master/config/enki.yml
Which I don't understand. I signed up for myopenID and replaced my username in the delegate, but I don't understand what goes under "open_id" - is it just my URL? I'm just not sure what's going on, or what ...
Songs on Rap Genius have paths like /lyrics/The-notorious-b-i-g-ft-mase-and-puff-daddy/Mo-money-mo-problems which are defined in routes.rb as:
map.song '/lyrics/:artist_slug/:title_slug', :controller => 'songs', :action => 'show'
When I want to generate such a path, I use song_url(:title_slug => song.title_slug, :artist_slug => song.a...
Hello.
I am trying to get my app up and running on heroku. However once I go to migrate I get the following error:
$ heroku rake db:migrate --trace
rake aborted!
An error has occurred, this and all later migrations canceled:
530 5.7.0 Must issue a STARTTLS command first. f5sm3554179qcg.2
/usr/local/lib/ruby/1.8/net/smtp.rb:576:in `au...
I am attempting to create an enrollment process similar to SO's:
route to an OpenID provider
provider returns the user's information to the UsersController (a guess)
UsersController creates user, then routes to the ProfilesController's new or edit action.
For now, I'm simply trying to create the user, then route to the ProfilesContro...
Look at the discussion on this thread . I am not able to follow how having a block to a fetch is a better solution.
...
Is there a reliable mechanism discussed in rails documentation for calling a function at the end of the request, regardless of filter chain aborts?
It's not after filters, because after filters don't get called if any prior filter redirected or rendered.
For context, I'm trying to put some structured profiling/reporting information int...
I recently played with MongoDB in Rails using Mongoid. I like the ability to define attributes for models within the model file (as opposed to in migrations):
class Person
include Mongoid::Document
field :name, :type => String
field :birthday, :type => Date
end
For projects that cannot use a schema-less database, does a similar ...
Hi:
I have three models and not sure how to define the correct associations in Rails.
The relationships for three models are as following
TaskTemplate has many TaskLineItems
TaskLineItems have order number (position of the item)
TaskOrder belongs to TaskTemplate
Task Order has one start task line item in the TaskTemplate it associate...
A user registers on our Rails app and they're given javascript to embed a widget in their website. The widget has a tabbed interface, like the JQuery tabs http://stilbuero.de/jquery/tabs_3/. iFrames have been tested, but the widget form factor and cross-domain policy negates the use of iframes. The widget is very dynamic and will often u...