I have a Model which has a belongs_to association with another Model as follows
class Article
belongs_to :author, :class_name => "User"
end
If I wanted to find all articles for a particular genre ordered by author I would do something like the following
articles = Article.all(:includes => [:author], :order => "users.name")
Howeve...
after installing
gem install rails --pre
then trying
rails -v
I get the following error
/home/luke/.rvm/gems/ruby-1.8.7-head@rails3pre/gems/activerecord-3.0.0.beta2/lib/rails: Is a directory - /home/luke/.rvm/gems/ruby-1.8.7-head@rails3pre/gems/activerecord-3.0.0.beta2/lib/rails (Errno::EISDIR)
from /usr/bin/rails:19:in `load'
f...
I'm to tracking dependencies with git-submodules in my rails app. So far I've added submodules for things like, haml, shoulda, and authlogic to 'vendor/plugins'. I've seen indications that I should be using 'vendor/gems' instead though.
Question: which directory is the appropriate place to put dependencies being tracked as submodules? I...
I'm trying to create a simple helper module in rails, and I'm stumped on the following error message from my new person form (app/views/people/new.html.erb):
undefined method `sort' for 97:Fixnum
Extracted source (around line #17):
14: <p>
15: <% nations = { 'United States of America' => 'USA', 'Canada' => 'Canada', 'Mexico'...
Hi There,
Continuing with my adventure to convert COBOL to a Ruby program, I have to convert a decimal digit to a comp-3/packed decimal format. Anyone know of a simple Ruby script or gem that does this?
Berns
...
I'm doing maintenance work on a Rails site that I inherited; it's driven by an Oracle database, and I've got access to both development and production installations of the site (each with its own Oracle DB). I'm running into an Oracle error when trying to insert data on the production site, but not the dev site:
ActiveRecord::Statement...
I have a strange error that came about when I changed my app from mongrel to mod_rails.
My app changes from a two column layout to a three column layout depending on where the user is in the app. My application layout relies on several helpers to put the divs in the right place.
In application_helper.rb:
def left_column_layouts
i...
I am trying to use rspec on my rails application
I run "spec path/to/spec/spec.rb" and it appears to do nothing and returns nothing. I receive no error
Rails Version 2.3.4
Ruby 1.8.7
Rspec 1.3.0
rspec-rails 1.3.2
Any help is appreciated. Thanks.
I'm still getting nothing when running "spec spec/models/fee_spec.rb" or any other *_sp...
Hi there,
I want to do a model class which associates to itself on Rails. Basically, a user has friends, which are also users. I typed the following inside a User model class:
has_many :friends,
:class_name => "User",
:foreign_key => :user_id,
:finder_sql => %{SELECT users.*
FROM
users INNER JOIN friends
...
I have the Ruby on Rails-based application Redmine (based on the BitNami redmine package) running on a Windows virtual server. It runs Apache, Mongrel, Ruby, and rails.
When, in a HTML page I am building a template for, I request a static image resource named /templates/mytemplate/images/bkg.jpg - around 15 kilobytes big - I get a 502 B...
Using Authlogic, the time format for @user.last_login_at" looks like this:
Mon Apr 12 16:52:56 -0400 2010
How can I mangle that into a more user friendly string?
...
With Ruby on Rails, is there a way for me to dump my production database into a form that the test part of Rails can access?
I'm thinking either a way to turn the production database into fixtures, or else a way to migrate data from the production database into the test database that will not get routinely cleared out by Rails.
I'd lik...
I have -- what I think -- is a simple question. Here's my code:
class Fruit < ActiveRecord::Base
end
class Apple < Fruit
end
class Kiwi < Fruit
end
Assume that I have all the STI setup correctly, and there are multiple types of Apple and Kiwi records in the table. From here...
fruits = Fruit.find(:all)
...how do I return an arr...
I have a the following rails models:
class Release < ActiveRecord::Base
has_many :release_questionnaires, :dependent => :destroy
accepts_nested_attributes_for :release_questionnaires
...
end class
class ReleaseQuestionnaire < ActiveRecord::Base
belongs_to :release
belongs_to :milestone
...
end class
In my view...
We use a bunch of specific apps/APIs that (unfortunately) differ quite a bit from dev to staging/production. We use tests and continuous integration at each stage, but in dev, the tests fail annoyingly (throwing dialogs, etc - thanks Windows for the 64-bit notification!). I hate to write custom code, but are there some best practices for...
For several of my cuke scenarios, I want to POST the user to a page with an object in the params, so that Rails will make a new object in the database. Is there a convenient way to send a POST+params to an action (either using something in cucumber or rails) or do I have to write my own function using Net::Http?
...
I'm running netbeans 6.8 on windows 7 pro (x64) with the bitnami stack and I'm using ruby 1.8.7-p72. Note: I can't change the version of ruby I am using because I am working with a team, this is a college project and we have only 3 weeks left before we have to hand it in. Changing the version of ruby at this time would be too much work...
I am creating a select box for a form using this in _form.html.erb
<%= f.select(:category_id,options_for_select(@cats)) %>
@cats is an array created in my controller like this:
@cats = []
categories.each do |c|
@cats.push([c.full_name,c.id])
end
The select box is properly filled, and the selected foreign key is even properly save...
Hi all, sorry for the blast.
I'm trying to connect to an SQLServer 2k5 using Ruby 1.8.7 over W2k3 with active record 2.3.5.
But, when I ran 'rake migrate' it throws the following:
rake migrate --trace
Hoe.new {...} deprecated. Switch to Hoe.spec.
Invoke migrate (first_time)
Invoke environment (first_time)
Execute environment
Execute mig...
I have a problem in a Ruby on Rails app that I am working on. I have been working on the app for months and I have never had this problem before and after a bit of Google searches I think that somehow someone is trying to steal cookies with javascript.
When I click on the link I get an alert box titled "the page at www.napkinboard.com s...