I'm using the Geokit plugin to calculate the distance between the current_user and other users (geocoding actually stored in Profile model).
For testing purpose, I created two Users, one in Minneapolis, MN and one in St. Paul, MN. I used the Geokit gem to geocode the Profiles' lat/lng pair in an IRB session.
I changed the Index view t...
My application has pages of two basic types: forms and tables.
As such, I have two different CSS files, forms.css and tables.css.
In my application layout file (application.html.erb), I'd like to load different stylesheets depending on some sort of flag set in a given view.
For example, <%= defined?(@tables) : stylesheet_link_tag 'ta...
I was wondering if anyone knows of rubyzip alternatives for Ruby, that can handle various formats in particular zip / rar / 7z?
I know of libarchive, but it's not complete for my purposes ( it's a good gem thou). (To clarify, libarchive - won't work for me - cause I need to be able to run in on Windows. ( Yeah I know sucks to be me))
...
I have the following association in my User model:
has_and_belongs_to_many :friends, :class_name => 'User', :foreign_key => 'friend_id'
I have the following uniqueness constraint in my user_users table:
UNIQUE KEY `no_duplicate_friends` (`user_id`,`friend_id`)
In my code, I am retrieving a user's friends --> friends = user.friends....
Hi,
I`m trying to add cache headers on my static files (.css, .js), but only way I found is with some .htaccess stuff that make the page to throw 500 error. So my question is whether there is easier way to add those headers?
Thanks in advance.
...
I have an array of structs called leaders. The struct class looks like this, for contextual info:
class Leader < Struct.new(:rank, :user); end
Two questions:
How do I sort the array of structs by rank?
How do I sort the array of structs by rank and by user.created_at?
...
My question is somewhat specific to my app's issue, but the answer should be instructive in terms of use cases for association logic and the record timestamp.
I have an NBA pick 'em game where I want to award badges for picking x number of games in a row correctly -- 10, 20, 30.
Here are the models, attributes, and associations in-play...
This seems like it should have a straightforward answer, but after much time on Google and SO I can't find it. It might be a case of missing the right keywords.
In my RoR application I have several models that share a specific kind of string attribute that has special validation and other functionality. The closest similar example I can...
Im getting SyntaxError: Parse Error, only on safari. Here is the code in question.
<script type="text/javascript">
$(document).ready(function() {
$("form").transload({
auth: {key: "b7deac9c96af6c745e914e25d0350baa"},
flow: {
encode: {
"use": ":original",
"robot": "/video/e...
I have two Rails applications (lets call them APP-1 and APP-2), each of them has a dependancy on a third Rails application (APP-3).
I would like to be able to run the tests for APP-1 and APP-2 in parallel on my CI server. The problem is, both need to start up APP-3 and write to a DB via the APP-3. This causes conflicts and failures ...
I've looked over the Arel sources, and some of the activerecord sources for Rails 3.0, but I can't seem to glean a good answer for myself as to whether Arel will be changing our ability to use includes(), when constructing queries, for the better.
There are instances when one might want to modify the conditions on an activerecord :inclu...
I'm wondering if theres a best practice for what I'm trying to accomplish...
First we have the model categories, categories, has_many posts.
Now lets say, users add posts.
Now, I have a page, that I want to display only the current user's posts by category.
Lets say we have the following categories: A, B, and C
User 1, has poste...
Just wondering if something like this exists ... or if there is something I can plug into a Rails or ASP.NET webapplication
...
Ok, so I had this working just fine before making a few controller additions and the relocation of some code. I feel like I am missing something really simple here but have spent hours trying to figure out what is going on. Here is the situation.
class Question < ActiveRecord::Base
has_many :sites
end
and
class Sites < ActiveRecor...
When building a rails app that allows a User to login and create data, is it best to setup a belongs_to :user association on every single model? For example, let's say a user can create Favorites, Colors and Tags.
And let's say Favorites has_many :tags and Colors also has_many :tags. Is it still important for Tags to belong_to :user ...
I am trying to restrict access to certain actions using a before_filter which seems easy enough. Somehow the ApplicationController is not recognizing that the current_user is the owner of the user edit action. When I take the filter off the controller correctly routes the current_user to their edit view information. Here is the code.
Li...
So let's say I have a form which is being sent somewhere strange (and by strange we mean, NOT the default route:
<% form_for @form_object, :url => {:controller => 'application',
:action => 'form_action_thing'} do |f| %>
<%= f.text_field :email %>
<%= submit_tag 'Login' %>
<% end %>
Now let's say that we have the ...
LoadError (Expected /web/zhao_backend2/app/controllers/admin_controller.rb to define AdminController):
/usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:249:in load_missing_constant'
/usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/depe...
I am looking for a system to parallelise a large suite of tests in a Ruby on Rails app (using rspec, cucumber) that works using JRuby. Cucumber is actually not too bad, but the full rSpec suite currently takes nearly 20 minutes to run.
The systems I can find (hydra, parallel-test) look like they use forking, which isn't the ideal soluti...
I set up facebooker to tunnel my Ruby on Rails application.
The issue is that I would like to test locally. That is, I don't want to have to start a tunnel every time I want to see my changes.
Right now, when I start the application using ruby script/server (not calling rake facebooker:tunnel:background_start beforehand), links create...