ruby-on-rails3

Rails 3, Bundler, LoadError

I'm writing an app that will run scripts in a specified folder, and then record the numbers and graph them. My problem is that if the script is a ruby file, the require statements fail inside the script because bundler seems to have done something funky with the load path. Running rails runner Datasource.run_jobs fails: class Datasou...

When installing JQuery, why does my "delete" link break?

I have a Rails 3 application that can create and delete products. An index page lists all the products. Next to each product in the list is a delete link: <%= link_to "Delete", product, :method => :delete, :title => "Delete" %> This looks like this in the HTML: <a href="/products/104" data-method="delete" rel="nofollow" title="Dele...

How do you configure WEBrick to use SSL in Rails 3?

Prior to Rails 3, you could modify the script/server file to add in SSL parameters and tell the server command to use the HTTPS version of webrick, now that all of those scripts are gone, does anyone know how to get this to work? ...

RVM & Rails 3 - rails command fires error: Is a directory

I installed Rails 3 by following this gist: http://gist.github.com/296055 But when I try "rails" in terminal I get the following error: /Users/yves/.rvm/gems/ruby-1.9.2-head/gems/activerecord-3.0.0/lib/rails: Is a directory - /Users/yves/.rvm/gems/ruby-1.9.2-head/gems/activerecord-3.0.0/lib/rails (Errno::EISDIR) from /usr/bin/rails...

Rails 3 with Rspec2 and authlogic: Cannot spec requests & views

I'm having trouble creating specs for my views and requests. Some of my controllers use named_scope, like this: #projects_controller.rb @projects = Project.with_user( current_user) ## project.rb: scope :with_user, lambda {|u| {:joins => :client, :conditions => {:clients => {:user_id => u.id} } }} but the following spec gives an ...

How to properly pass collection for input in Formtastic

I need to pass a collection to the standard select input in Formtastic: f.input :apple, :as => :select, :collection => Apple.all The problem is, though that I need Formtastic to access a different method than name. Now this is really a problem. I can always pass the Array f.input :apple, :as => :select, :collection => Apple.map { |a|...

When is it Appropriate to use Custom Classes in a Rails Application?

This is a complicated question with many possible answers, so I'll break down my situation into simple bullet points to help narrow down the solution: My Rails App Has the Following 'Objects' Author Feed Update FeedTypes The Objects are Related Like So: Authors can have 1 or more Feeds Feeds can have one or more Updates A Feed has...

Rails3 nested has_many through question

We are planning to upgrade our application to Rails3. One plugin we've used quite a bit is nested_has_many_through. This plugin seems outdated, and no longer maintained, and simply does not appear to be working in a new Rails3 application. A simple example: Author.rb has_many :posts has_many :categories, :through => :posts, :uniq => tr...

Rails 3 finding object in a HABTM relationship

Have myself confused . . . I have a SubscriptionPlan ActiveRecord object which has an HABTM to available_to_roles. In Rails 3 I'm trying to create a scope or class method on SubscriptionPlan to get appropriate subscription plans: def self.available_subscription_plans(users_roles) #users_roles = Array of roles #query to find all sub...

How do I vendorize gems for Rails3/Bundler

In Rails 2.X, I could simply copy gems into vendor/gems/gem_name, or use the rake command rake gems:unpack. Since Rails3 uses bundler, it doesn't appear to work anymore. I have found the command bundle package, but it doesn't work the same way. Edit: So, just to elaborate a bit on this: The way that rails 2 worked, I could easily grep...

How to stop will_paginate from getting every post from the database

I am just playing around with Ruby on Rails 3.0 with a simple message board and found several issues with will_paginate. The most pressing is that each time a new page is displayed a database query of every single post in the topic is performed. As you can imagine, if you have a topic with 10,000+ posts this is very slow. Is there a ...

Simple Admin functionality in Rails 3

Hello, I want to add a admin functionality to my webapp with Rails version 3. I want something very simple, there will be only one admin, this funcionality doesn't need a username field, just a password field. I don't know how to do it, can you help me? Thanks! ...

Rails 3, how to roll back a Migration file?

Hello, I have the following Rails 3 migration file db\migrate\20100905201547_create_blocks.rb How can I specifically roll back that migration file, allow me to the do: rake db:reset, followed by rake db:migrate? ...

Rails 3, help controlling access to a record based on the user id

Hello, I'm a Rails newbie.... Here's what I'm trying to do.... I created a scaffold for notes (t.text :content, t.integer :user_id) What I want to do now is only allow user's to view notes that they created. ie (== user_id) In my /app/controllers/notes_controller.rb I have the following: class NotesController < ApplicationController...

Rails 3 deprecated methods and APIs

Where can one find a list of deprecated methods, APIs, etc, in order to upgrade from Rails 2.x to Rails 3? ...

Install Rails 3 on OSX with RVM

Trying to install the new Rails 3 release on OSX 10.6. Have never touched Ruby or Rails on this machine since purchased. I was able to get rvm and get Ruby 1.9.2. installed. From there, I am stuck. I tried: rvmsudo gem install rails -v 3.0.0 sudo gem install rails --pre sudo gem install rails sudo gem update rails And I get the sam...

Why was :overwrite_params deprecated in Rails 3

With overwrite_params, I was doing this to prepare a PDF request for a page: url_for(:overwrite_params => {:format => :pdf}) overwrite_params has been deprecated after Rails 2.3.8, is there a reason for this deprecation? What's the standard accepted alternative? ...

Factory_girl has_one relation with validates_presence_of

I have 2 Models: # user.rb class User < ActiveRecord::Base has_one :profile, :dependent => :destroy end # profile.rb class Profile < ActiveRecord::Base belongs_to :user validates_presence_of :user end # user_factory.rb Factory.define :user do |u| u.login "test" u.association :profile end I want to do this: @user = Factory...

Technically, isn't it "Rails on Ruby" instead of Ruby on Rails?

More and more people just say Rails instead of Ruby on Rails nowadays... and isn't it Rails, which is developed on top of Ruby, so it is really Rails on Ruby? Update: when people say: I am using Rails, that means it is Rails they are using. When people say: I am using Ruby on Rails, that means they are using Ruby that happens to be on ...

i18n assets management / translation UI

Hello everyone, i'm building a multi-lingual webapp with i18n from the ground up, and while i myself can deal with an army of yml files, the languages i speak are ( very ) limited, and would eventually like to ask for outside help. I'd like to know if anyone here is using a UI plugin/gem ( not unlike django-rosetta on django ) to deal ...