I am running:
[~/ruby/rails/sas]$ ruby --version
ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
on Mac Snow Leopard 10.6.3
Can anyone help to explain why the Float and BigDecimal subtraction can be this wrong.
[~/ruby/rails/sas]$ console
Loading development environment (Rails 2.1.1)
>> num = 30.0
=> 30.0
>> num.class
...
i get rake migrate errors when trying to load a model in migration files that has paperclip associations like: has_attached_file
def self.up
add_column :users, :events_count, :integer, :default => 0
u = User.find(:first)
u.update_attribute :events_count, u.events.length
end
The User model has a paperclip association: "has_attac...
Hi!
I want to create a framework fo rails application. It will be a rails application but packed into gem (like a Radiant CMS).
It must work like this:
gem install cmsframework
and then:
cmsframework the_app
After that we have a sceleton of rails app without any controllers etc.. - all controllers loaded from cmsframework gem.
If...
I'm using Cucumber and Capybara and I'd like a way to simulate the request IP address, like this:
Given the request ip address is "10.1.2.3"
...
Hey guys,
The website that I'm building includes a section where two users can interact. I think I know how to do most of it, except the actual session sharing part. I'm using Ruby on Rails & Javascript (jquery), and I've got user login and session management all working okay. Would the best way to create a shared session be to have a S...
I'm working with Ruby on rails 2.3.8 and my base app came with Gravatar functionality. I'd like to know if there's a way to programmatically upload a different gravatar in my application.
...
1)Url field should also accept url as “www.abc.com”. If user enters url like this, it should be automatically appended with “http://” resulting in value saved in database as “http://www.abc.com”. If user enters url as “http://www.xyz.com” system should not append “http://”. User should be able to save url with “https://”. ...
I'm attempting to upgrade the friendly_id gem in a rails project.
I have removed the old gem from the vendor directory, installed the new gem from rubygems.org. When I type:
rake gems:unpack
I get the following response:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/lib...
Whats the best way to enable users to log in with their email address OR their username? I am using warden + devise for authentication. I think it probably won't be too hard to do it but i guess i need some advice here on where to put all the stuff that is needed. Perhaps devise devise already provides this feature? like in the config/in...
I have two models:
Program < ActiveRecord::Base
has_many :events
def federal_financing
events.sum(&:federal_financing)
end
def regional_financing
events.sum(&:regional_financing)
end
def local_financing
events.sum(&:local_financing)
end
end
Event < ActiveRecord::Base
belongs_to :program
# events table h...
Hey Guys,
Lets say the model for books is:
created_at
user_id (int)
author_id (int)
genre_id (int)
pages (int)
I want to let people change the "created_at" field upon record creation. I also want to make sure that a record can't have the exact same created_at, user_id, and author_id as any other record (i.e. each needs its own date)....
I'm developing a rails project where I have one data model with multiple fields that are collection selects. I'd like to create another model to represent all of these collection select fields. So, for instance, my main data model has three collection select fields -- one for county, one for category, and one for classification. I could ...
Hi Everyone,
I have a model called Kase each "Case" is assigned to a contact person via the following code:
class Kase < ActiveRecord::Base
validates_presence_of :jobno
has_many :notes, :order => "created_at DESC"
belongs_to :company # foreign key: company_id
belongs_to :person # foreign key in join table
belongs_to :survey...
I have a quite long slideshow of images, all rendered via the awesome Paperclip.
Those images won't change very often, so I'd like to make use of browser caching.
Problem is Paperclip appends a unique load id to the image url.
(eg: pancakes.png?1275839986)
Is there any way to prevent this from happening?
Thanks!
...
C:\rubygems-1.3.7>gem install rails ruby-debug capistrano rspec ZenTest webrat image_scie
nce mini_magick mechanize RedCloth fastercsv piston sashimi ruport json newgem open4 rubi
gen --no-ri --no-rdoc
WARNING: RubyGems 1.2+ index not found for:
http://rubygems.org/
http://gems.rubyforge.org
http://gems.rubyfor...
I am building apps for a non-english audience. Right now, I use english nouns to name my models, yet I prefer to use native dutch ones. As the convention uses the plural of the class name for tables, I assume it is the pluralize method inside Rails (where it resides, I wouldn't know). How can I change the pluralize method and where is it...
I am using ActiveRecord in Rails 3 to pull data from two different tables in two different databases. These databases can not join on each other, but I have the need to do a simple join after-the-fact. I would like to preserve the relation so that I can chain it down the line.
here is a simplified version of what I am doing
browsers ...
I'm trying to upgrade a rails application which requires rails-2.3.5 which in turn seems to require rack-1.0.1. Many (many!) attempts of each of the following hasn't worked:
# gem install rails -v=2.3.5
ERROR: could not find gem rails locally or in a repository
or
# gem install rails -v=2.3.5 --source http://gems.rubyforge.org
WA...
I've got a model with its validations, and I found out that I can't update an attribute without validating the object before.
I already tried to add on => :create syntax at the end of each validation line, but I got the same results.
My announcement model have the following validations:
validates_presence_of :title
validates_prese...
I have a Rails app that processes and serves up jpg files that were uploaded via FTP. On several occasions the FTP process was disconnected and left many incomplete .jpg files. I was surprised to see that the incomplete jpgs behave as normal jpg files in my app even tho they have incomplete image data.
I have since implemented a more ...