Hey all,
I have a table containing a number of records with their long / lat coordinates. I'm trying to do the common "Show all within X miles" type search where my point of origin is the user's current long / lat pulled using geolocation in the browser.
Does anyone know an efficient away to calculate the distance between my point of...
I have 2 models, say Model A and Model B, each one having certain fields (a1,a2,a3) and (b1,b2,b3).
I ran the scaffold command to generate the controllers and views for the models.
Now,
What i want to do is: -
On the new page of model A, I want to add a button/ href lin to create a new B object.
When the user clicks the button, ...
In a RoR migration, how do I auto increment a non-primary-key field? I'd like to do this in the db definition, and not in the model.
...
Is there a command in TextMate to re-indent or format text in a file?
I use this all the time in IDE's after pasting in a block of code, removing a block, etc for re-indenting a file.
Bonus points if there is a way to pretty indent, turning this:
has_many :users, :class_name => 'Users', :dependent => :destroy
has_many :comments, :clas...
Is it possible to map your routes inside of Controllers? I prefer having my routes defined near my controller actions.
...
UPDATE: SOLUTION AT BOTTOM
I'm hoping someone else has spent some time ironing out this same issue... I'm building an address book within an rails application, and I have an Person model and an Email model. Person has_many Emails, and Person accepts_nested_attributes_for :emails.
This all works perfectly -- I have a nested form with w...
Currently I have Ruby 1.8.7 and Rails 2.3.8. Is it possible to update ruby so that I do not have to re-install all the gems again?
...
I'm trying to find all users except for users with an id that is a member of an array exclude_ids
Here's what I have:
User.where("id != ?", exclude_ids)
This only works when exclude_ids has only 1 element. If it has more than one element, I get
this error:
ActiveRecord::StatementInvalid: SQLite3::SQLException: near ",": syntax er...
Hi all,
I have a Rails background and am trying to muck through Core Data. How does Core Data handle complex :has_and_belongs_to_many =>, :through => relationships?
As an example, suppose you were modeling open source project contributions. You might set up a table structure such as:
Contributor Contribution P...
I need to get populator to build me an order history such that:
The record has a start_date and end_date
Each record specifies a period between 0 and 5 years
Events are pretty much consecutive (meaning the end date of record n affects the start date of record n+1)
There can be gaps between events (periods of no orders) but no overlaps
...
This is a simple issue but I have multiple cases in my populate file where I want to set order.link_id to any link where link.job_id = j.id.
Order.populate 1 do |order|
@links = Link.find_all_by_job_id(j.id)
order.link_id = @links.find(:first, :offset => rand(@links.count)).id
...
end
This produces an error (2 arguments for ...
Does Rails do any kind of automatic (time-based?) caching expiration for pages/actions/fragments? This seems like such a simple question, yet I can't find it anywhere (or maybe I'm looking in the wrong place).
...
I love Capistrano and finally i found GUI for using it!
Webistrano!
I installed the app that many other guys recommend it to me.
Finally, its time to try... I flow the screencast ..etc.. and found in my production.log this error: 'sh: ruby command not found'
I followed this blog post but naaaah!! same problem...
This is what i tried...
I get the following error on any call to rake. I am working on a Rails 3 running on JRuby (1.5.1) installed with RVM. I don't think this was always the case, but I'm not sure how to track it down. Am I correct in think this has something to do with the gems I have installed (listing included below)?
$ rake metrics:all
/Users/Eric/.rv...
I am starting to have some difficulty making this more DRY:
http://gist.github.com/471225
The gist of it is this:
I have a bunch of Models, contact_email, contact_call, contact_letter, etcetera.
They essential were a way for me to instantiate instances of the Email model (think of it as a template) matched with a specific instance/re...
What's content caching (like this plugin here: http://blog.codahale.com/2006/04/10/content-only-caching-for-rails/) vs page/action/fragment caching that Rails has built in?
I'd like to do caching on my Rails application, but I don't quite know which type to use. My application has mostly dynamic, user specific data on every page. Is cac...
My Facebook Connect Rails application worked earlier today, but seems to have stopped getting the Facebook sessions properly.
I'm using the Facebooker gem to handle the interaction with Facebook. All of a sudden, my application started throwing this exception, both while I was logged in to my Facebook account and while I was logged out ...
Hi,
I'm working on OpenID authentication in my Rails app.
Because Authlogic seems to be received well by the community, I gave it a try.
I got to the point where I can register a new user with an OpenID URL. However, when I tried logging in with the URL I signed up with, I keep receiving a message: "Openid identifier did not match ...
I have a simple messaging system in Rails with a Message table for the original information and a MessageCopy table for each recipient's information.
Message includes job_id, subject, body, and author_id.
MessageCopy includes recipient_id and message_id.
I am trying to isolate a specific set of messages. I need the recipient to see all...
In Rails 3 (currently using Beta 4) I see that when using the form_tag or form_for helpers there is a hidden field named _snowman with the value of ☃ (unicode \x9731) showing up.
So, what is this for?
...