ruby-on-rails

Rails 3 If Statement,,, IF XXX Equals At Least One (Var1, Var2, Var3)

Is the following statement possible with Rails/Ruby? If so, how :) IF XXX Equals At Least One (Var1, Var2, Var3) ...

Rails 3 - Obtaining the Lates Observer Record

Here's the current flow in my Rails App 1. User uses AJAX and creates a Photo record (stored in DB) 2. Then, the observer catches this and adds a record to the audit log ** That was all without a page refresh. The challenge I have now is that I need to have AJAX return a "news feed" item from the AuditLog created by the observer. It nee...

Overriding the JavaScript template used in a Rails remote form submission

I've got a Rails app that doesn't seem to be triggering the expectedly named .js.erb file, so I'd like to override the default behavior, but I'm not sure how. The details: It's a Rails 3 app that renders a button_to with an AJAX call to toggle the status of something on the backend and then modifies the text of the button to reflect th...

'deadlock detected' error in rails

Hi, I have deadlock detected error in my code and don't understand why. Could someone please tell me what am I doing wrong? #!/usr/bin/ruby ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development' require File.expand_path(File.dirname(__FILE__) + "/config/environment") mutex = Mutex.new threads = [] 1.upto(10) do |i| t...

Rails references...

Let's say that you have a foreign key called COMPANY_ID in the table PERSON. In the model PERSON, can you write? validates_presence_of :company_id or validates_presence_of :company or both? Which is the preferred and why? ...

when i am trying to use "rails server", i got an error

$rails server JRuby limited openssl loaded. gem install jruby-openssl for full support. http://jruby.kenai.com/pages/JRuby_Builtin_OpenSSL Could not find gem 'sqlite3-ruby (>= 0, runtime)' in any of the gem sources. Try running `bundle install`. ...

Is this possible? Edit new object accross more than one view without saving

Hello, I have a screen where a user can define new data records. There are several different fields in a data record where different images with various sizes can be added. To make it nice for the user to add all these images I'd like to separate the image upload portion to a greyboxed view. The layout flow would become Click new -...

Capistrano deployment failed.

Got the following error while trying to cap deploy:setup. It's like it failed to upload the database.yml file via sftp. I googled everywhere but had no solution. Not even a bit. * upload via sftp failed on xxx.xxx.xxx.xxx: Net::SFTP::StatusException (Net::SFTP::StatusException open /var/www/domain.com/username/shared/config/database....

Open Flash Chart 2 - the ids are the same so multiples are not displaying

I can get one successful Open Flash Chart per view. I'm now trying to support multiple Open Flash Charts per view but the source code shows that the ids for both generated divs are the same: # javascript at top of view <%= javascript_include_tag "swfobject.js", :cache => true %> # view itself <%= @graph.html_safe %> # html_safe is ne...

Should a model method call 'save' itself?

Let's say that we have a method inside a model that needs to called only on saved records may update the model itself and thus the model needs to be saved again afterwords Should the "save" calls happen inside the method itself like the following code def result save! if new_record? # do some funky stuff here that may also cha...

Heroku command: Heroku Rake db:migrate fails

When I run Heroku db:migrate I get an error: rake aborted! no such file to load -- sqlite3 /disk1/home/slugs/313735_a606978_6916/mnt/Rakefile:4 (See full trace by running task with --trace) (in /disk1/home/slugs/313735_a606978_6916/mnt) When I do heroku rake db:push I succeed. Do I need to install something on the Heroku server? ...

Rails 3- Will_Paginate - Making the Pagination links more like GMAIL

Hello, I'm using the Rails 3 plugin Will_Paginate and have been using the following tutorial to learn how to customize the pagination links: http://thewebfellas.com/blog/2010/8/22/revisited-roll-your-own-pagination-links-with-will_paginate-and-rails-3/ My question is, how to make the pagination links more like GMAIL, example: 1 - 100...

Rails - Handling Remote Requests

From a Rails controller, is there a way to determine if the request was from a remote link or form submission? I'd like to use a redirect to the 'show' url in the case that a record is created without remote, and simply display the 'show' template in the case that it's a remote call. Thanks. ...

rails-upgrade gem on Windows

Hey, I'm trying to run rake rails:upgrade:check --trace on Windows on my Rails 2.3.8 project and get this error: rake aborted! no such file to load -- initializer <internal:lib/rubygems/custom_require>:29:in `require' <internal:lib/rubygems/custom_require>:29:in `require' ... Looked all over the internet and didn't find solution yet....

Rails 3 - Understanding attr_accessible with paper_clip

Hi... Just started learning how to use paper_clip. I installed everything according the instructions and tried to upload an image (profile_pic)... I got the error that I can't mass assign profile_pic... so I added attr_accessible: :profile_pic And that stopped that error. What I'm curious about is I don't have a 'profile_pic' column i...

Current version of the rmagick gem (2.13.1) doesn't work with current version of ImageMagick (6.6.4)

I'm on OSX Snow Leopard though I think this may not be a platform-specific issue. The problem is I've wasted hours of my life trying to get gem install rmagick to work and I'm hoping to save the next person that grief. I believe the core problem is summed up in the title. Questions: Can anyone confirm that Rmagick 2.13.1 doesn't work ...

Deploying RoR app to Heroku with Sqlite3 fails

I'm trying to deploy my first app to Heroku. I'm using Sqlite as the database. As far as I know Heroku doesn't use Sqlite - it switches to Postgres in the backend. When I'm deploying I get the following error: /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require': no such file to load -- sq...

Recommended database design for relationship between business hour and it's staff and their hours

Been going back and forth on how to architect this. I'm using rails,and started with Single-Table-Inheritance, then changed my mind, now I'm not sure. BusinessHours business_id, day_of_week, start_time, stop_time StaffHours staff_id, day_of_week, start_time, stop_time Obviously a staff member belongs to a business, however the tables ...

cumulative sum per day in rails&postgresql

Hi, Ive got a table 'donations' which is filled (by users) on a daily basis. I would like to create a graph that shows the cumulative number of donations per day. So, table donations: id created_at 1 19/01 2 20/01 3 20/01 4 21/01 Should become: [1,3,4] How to do this with rails3&postgresql? Thanks in advance ...

Keep getting nil error everywhere. ruby/rails 3

I get a NoMethodError: undefined method `get_best_compatible' for nil:NilClass in mail `from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:in 'method_missing'from /usr/lib/ruby/gems/1.8/gems/mail-2.2.7/lib/mail/body.rb:143:in 'get_best_encoding' from /usr/lib/ruby/gems/1.8/gems/mail2.2.7/lib/mail/mes...