ruby-on-rails3

How do I display two different objects in a search?

github url I am using a simple search that displays search results: @adds = Add.search(params[:search]) In addition to the search results I'm trying to utilize a method, nearbys(), which displays objects that are close in proximity to the search result. The following method displays objects which are close to 2, but it does not displ...

Eager-loading association count with Arel (Rails 3)

Simple task: given that an article has many comments, be able to display in a long list of articles how many comments each article has. I'm trying to work out how to preload this data with Arel. The "Complex Aggregations" section of the README file seems to discuss that type of situation, but it doesn't exactly offer sample code, nor do...

How do I combine two methods into one json formatted variable?

I'm storing JSON formatted data into a var adds with the following methods: var adds = <%= raw @add.to_a.to_json %>; var adds = <%= raw @add.nearbys(1).to_json %>; The first line of code stores the location of an individual in JSON format, the second line of code searches for that person's neighbors, within a 1 mile range. How do I c...

Rails 3 bundle permissions problem

I get this error message from Passenger: Permission denied - /root/.bundle/ruby/1.8/specifications/activeresource-3.0.0.beta2.gemspec Does anyone recognize it and can tell me how I can find a solution? I'm really stuck… The server runs Ubuntu 9. ps. The problem occured after I ran a deploy in which I'd added to the Gemfil gem "...

Mocha no longer can be loaded after installing will_paginate 3.0pre

So I came about the strangest rails bug. I have been starting a new rails3 app, and just installed will_paginate 3.0pre. Unfortunately the rails 3.0.0.beta2 update made some of will_paginate 3.0pre code deprecated. I did a quick fix. In gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb: ... #railtie_name :will_paginate #Old co...

Rails 3 - yield return or callback won't call in view <%= yield(:sidebar) || render('shared/sidebar') %>

Hey folks, I'm migrating a Website from Rails 2 (latest) to Rails 3 (beta2). Testing with Ruby 1.9.1p378 and Ruby 1.9.2dev (2010-04-05 trunk 27225) Stuck in a situation, i don't know which part will work well. Suspect yield is the problem, but don't know exactly. In my Layout Files I use the following technique quite often: app/views...

trying to convert rails 2.3.4 app to rails 3 but views not appearing

I have a simple rails 2.3.4 application I am trying to get running with rails 3.0.0-beta2. I have the server running and all my links and navigation showing, however for some reason the content of my views is not displaying. When I navigate to Site/index the html in my index.html.erb in my site view is completely ignored. There are no ...

Is there an ActiveRecord equivalent to using a nested subquery i.e. ... where NOT IN(select...) ?

I have 3 models: Category, Account, and SubAccount The relations are: Accounts has_many :sub_accounts Categories has_many :sub_accounts I wanted to get a list of all Categories that are not used by a given account. My method in the Category model currently looks like: class Category < ActiveRecord::Base def self.not_used_by(ac...

What happened to Builder::XmlMarkup in Rails 3?

I'm struggling with the atom_feed method in a RoR 3 project. The method complains about a undefined local variable or method `xml' error so I tried passing the XML builder as an option to the atom_feed (i e atom_feed({:xml => Builder::XmlMarkupet.new})) but when doing so I get a NameError: uninitialized constant Builder exception ins...

Rails 3 HTTP digest authentication

Is HTTP digest authentication still supported in Rails 3? I tried the following code in Rails 2.3.5, it works. class Admin::BaseController < ApplicationController before_filter :authenticate USERS = { "lifo" => "world" } def authenticate authenticate_or_request_with_http_digest("Application") do |name| USERS[name] e...

What to Learn: Rails 1.2.4 -> Rails 3

I've recently convinced my management that our outdated version of Rails (1.2.4) is slowing us down enough to warrant an upgrade. The approach we're taking is to start a fresh project with current technology rather than a painful upgrade. Our requirements for the project have changed and this will be much easier. The biggest problem is ...

Exclusive filtering by tag

I'm using rails 3.0 and MySql 5.1 I have these three models: Question, Tag and QuestionTag. Tag has a column called name. Question has many Tags through QuestionTags and vice versa. Suppose I have n tag names. How do I find only the questions that have all n tags, identified by tag name. And how do I do it in a single query. (I...

Silencing Deprecation warnings in Rails 3

Can anyone tell me how to silence deprecation warinings in Rails 3? I have a few situations where it is throwing false positives. Namely using - for loops in haml and f.error_messages from the dynamic_form plugin. Thanks ...

Uploadify and rails 3 authenticity tokens

Hi chaps, I'm trying to get a file upload progress bar working in a rails 3 app using uploadify (http://www.uploadify.com) and I'm stuck at authenticity tokens. My current uploadify config looks like <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $("#zip_input")...

Sample app for Rails 3?

Can someone point me to a solid sample app that shows how to use the new features and syntax of Rails 3? It's been answered before for earlier versions (http://stackoverflow.com/questions/248371/whats-the-best-open-source-ruby-on-rails-project-to-learn-from), but I have not seen one for Rails 3. Specifically the following: Routing Ma...

Rails 3 beta 3 -- is it time to start using this for new projects?

Is it time to start new projects in Rails 3? I'm nervous about using beta versions but at the same time I really like what they are doing and don't want to deal with legacy 2.3.5 issues with these apps. Is it better to wait these things out, or buckle-up, deal with early adopter issues and get a head start on the future. Thanks for any...

Rails 3 authetication with OpenID, Twitter or Facebook

Can you suggest some working example of it? I tried Authlogic and Devise withous success. ...

Nested resources in namespace form_for

Problem The form_for helper incorrectly determines the path to my nested resource inside of a namespace. The models in question are: Forum::Thread and Forum::Reply respectively, located in a subfolder called "forum" under my models directory. This is in Rails 3 BETA 3. routes.rb namespace :forum do root :to => 'threads#index' ...

Rails 3 - Category Filter Using Select - Load Partial Via Ajax

Hey. I am trying to filter Client Comments by using a select and rendering it in a partial. Right now the partial loads @client.comments. I have a Category model with a Categorizations join. This all works, just need to know how to get the select to call the filter action and load the partial with ajax. Thanks for you help. Categories c...

Using Rails 3 and Haml 3, how do I configure Haml?

I'm using Rails 3.0.0.beta3 and Haml 3.0.0.rc.2, and I can't find where I need to place the configuration lines for Haml (nor what they are in the new version, for that matter). Using Rails 2.3.5 and Haml 2, I would do Haml::Template.options[:format] = :html5 in environment.rb. Or, in Sinatra, set :haml, {:format => :html5} in my m...