ruby-on-rails

Installing new plugin in netbeans

Hi, I am using Netbeans 6.5.1(on windows) for rails. I am trying to add new plugins from the rails console like for example ruby script/plugin install svn://svn.seesaw.it/tabnav But this pops the foll error : (irb):1: syntax error, unexpected tIDENTIFIER, expecting kDO or '{' or '(' ruby script/plugin install svn://svn.s...

acts_as_taggable_on: query for users tagged with any of these tags

I'm using acts_as_taggable_on and I'm trying to query for all users tagged with any of the tags in the collection tags Right now I'm doing: tags.map(&:name).each { |name| @result.push User.tagged_with(name) } Is there a way that I can do this in one query, and not tags.size queries? I'd appreciate any help. ...

Adding a Rating to each User per category on Ruby on Rails

Right now I'm building a social media app, where i want an user to have a rating per category, how would the association go? The way it needs to be setup it's Each user will have a different rating in each category. I'm think that belongs_to :user belongs_to :category in the UserCategoryRating model. and has_many :user_category_r...

combining jquery accordion and rails nested forms

Hi, I'd like to generate a form with nested object forms like this (in haml): - form_for @parent do |parent_form| - parent_form.fields_for :children do |child_form| = child_form.label :first_name = child_form.text_field :first_name ... and I'd like to place the child forms in a jquery ui (1.8.2) accordion, like this (I think...

Problem with URL escaping in Rails

I use Rails RESTful routing to generate URLs for one resource in my application. My resource ID contains some special characters. The confusing part is that in the generated URL, when I look in the HTML, is double escaped. For instance, /item/item+one get escaped to /item/item%252Bone instead of /item/item%2Bone. When getting the ID par...

Rails Environment specific logs

So I just deployed my first rails app (using passenger) and I have set - RailsEnv test I was looking at the test.log and its empty. So I have a few questions on rails logs - I don't see development like logs in test.log - things like details of request & SQL etc Okay may be test != development, that why?? Also, I tried this in my c...

Newbie Rails HABTM association not working

I'm new to Rails and trying to create a has_and_belongs_to_many relationship between orders and items. class Order < ActiveRecord::Base has_and_belongs_to_many :items end class Item < ActiveRecord::Base has_and_belongs_to_many :orders end Migration for Orders (not shown. very basic) Migration for OrderItems: class CreateItems ...

'Splitting' ActiveRecord collection

Let's say I have two models Post and Category: class Post < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base has_many :posts end Is there a method that will allow me to do something like posts = Post.find(:all) p = Array.new p[1] = posts.with_category_id(1) p[2] = posts.with_category_id(2) p[3] =...

google geocoding limit

there is a limit of 2400 geocoding request for google service. even if each request is cached and not duplicated its possible to exceed this limit if the request is being made from a rails app. short of purchasing the premium package(which i dont know the cost of), what else can one do? thanks ...

ruby on rails multiple object in find condition

Hi How can I add multiple objects in a find condition? I created a table for comment but I want to display comments posted by a user and His or her friends. I got the find method to return a list of comments by a users friends but I cannot get the Find method to include the user as well. For example User = profile.find(1) Comment.fi...

What parts of Rails can be used even if you're not building a web site?

What parts of Rails have you used even when you're not building a web site or web services? For example, some people use ActiveRecord by itself. ...

Recommended TextMate Bundles for Ruby on Rails Development

Can you guys please recommend few textmate bundles that would be helpful while developing ruby on rails applications ...

Rails find_by macros with a has_many relationship

I'm having trouble with the Dynamic attribute-based finders in rails. They don't seem to exits for my model. class Person < ActiveRecord::Base belongs_to :team end class Team < ActiveRecord::Base has_many :people end So in script/console, to find the teams having person with ID 1, I should be able to do: >> Team.find_by_person...

Rails - Custom config in environment config files?

Is it possible to define custom configuration in config/environments/*.rb or config/environment.rb file. Is yes, how do i access them from my code (controller, model, library, helper) Thanks. ...

page cache in rails

My home page is largely the same for all users, which makes it a candidate for page caching. however, there are a couple of things that are user specific. For example, there is a nav item that is only shown for logged in users and there is a link like logout, my profile etc, generated for specific users. Do I have to use fragment cachi...

Rails3: linking to offsite mp3 files and have them save to user's hard-drive rather than stream in the browser

I have some very large mp3's stored at a remote location and I presently link to them like so: = link_to "mp3", "http://website-where-file-is-stored.com/file-123456.mp3" When a user clicks the link, the file starts to play in the browser. I would like the file to download to the users hard-drive after they click the link. I've read a...

Gem installed rails 2.3.8, but not generate rdoc, how to fix?

I use gem install rails -v=2.3.8 to install rails, and it says rdoc and ri has been generated. But when I gem server, I can't open the rails doc in browser, it says doc_root/rails-2.3.8/rdoc/index.html not found I looked into /usr/local/lib/ruby/gems/1.8/doc/rails-2.3.8/rdoc, found it is empty. How to fix it? How to generate the rdoc ...

Changing type of ActiveRecord Class in Rails with Single Table Inheritance

I have two types of classes: BaseUser < ActiveRecord::Base and User < BaseUser which acts_as_authentic using Authlogic's authentication system. This inheritance is implemented using Single Table Inheritance If a new user registers, I register him as a User. However, if I already have a BaseUser with the same email, I'd like to ...

'validates_presence_of' doesn't work well in Mongoid?

There are two classes: class Person include Mongoid::Document field :name embeds_many :addresses end class Address include Mongoid::Document field :city field :street validates_presence_of :city, :street end We can see, we have validated the city and street should be present. But see following code: person = Person...

Problem running Rails/Passenger app on slice that also serves static html sites

I'm running a Rails app on an ubuntu hardy box with passenger. I also have a couple basic html sites running on the same box. My problem is that the apache vhost set up for the html sites seems to be blocking my Rails app from resolving at the proper url. I have a number of Rails apps running on different slices using passenger, so I ...