ruby-on-rails

A migration to add unique constraint to a combination of columns

I thought this mus have been answered before, but I didn't find any pointer from my searches. May be I tried with wrong key words. What I need is a migration to apply unique constraint to a combination of columns. i.e. for a Person table a combination of Firstname, LastName and Dob should be unique. ...

Amazon S3 AWS + Texticle search on Heroku

I'm using Texticle to do full-text search on Heroku. It's working great. I'm now trying to setup nightly db backups to Amazon s3 using this script. When I try heroku rake backups:backup I first get this error: /disk1/home/slugs/245176_566b3d9_4845/mnt/.bundle/gems/bundler/gems/texticle-3a96c70a9fa60921197f0027204a23824435b142-ee972f...

flash[:notice] is shown on browser back again

Hej, i have a problem: I'm using flash[:notice] in my rails app. A User comes to the page and creates a new object. The flash-message says "Created." Now he clicks on a link on the page. If he is coming back by using the "back" button of his browser the flash massage is presented again. flash.now[:notice] doesnt work either (i think a...

Mongrel cluster does not start on Snow Leopard

Hi, I fail to deploy my ruby (v1.8.7) rails (v2.3.5) application on Snow Leopard (10.6.3). After "cap deploy", the Mongrel-cluster (v1.1.5) fails to start up with the following output in mongrel.*.log: ** Daemonized, any open files are closed. Look at tmp/pids/mongrel.8000.pid and log/mongrel.8000.log for info. ** Starting Mongrel l...

(ActionView::MissingTemplate) Error when deploying app to heroku

I have a 'pages' controller with some static pages instead of using the rest method (show, index etc). The static files view fine on my local machine but when deploying with heroku I get the following error: PagesController#used_cars_south_wales (ActionView::MissingTemplate) "Missing template pages/used_cars_south_wales.erb in view ...

`load_missing_constant': uninitialized constant Rails::Railtie

Hi All, I run rake gems:install rake gems:unpack If i add configure the rspec-rails gem in config/environment.rb: config.gem "rspec-rails", :version => ">= 1.3.2" and then run server. I am getting this error: /home/Amit/Myworkspace/MyApplication/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning:...

Mysql gem with MAMP

Hi, I'm running MAMP for local development on Snow Leopard (64bit obviously). I'm trying to run a rake task for a ruby on rails application and get the following error: " !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. !!! The bundled mysql.rb driver has be...

crash on website

I have a crash on my system. log for the crash is :ActionView::MissingTemplate (Missing template public/422.html in view path app/views): app/controllers/application_controller.rb:148:in `check_user' fcgi (0.8.8) lib/fcgi.rb:117:in `session' fcgi (0.8.8) lib/fcgi.rb:104:in `each_request' fcgi (0.8.8) lib/fcgi.rb:36:in `each' d...

What is the best way to collect a user's timezone without explictly asking the user ?

For my project(a web and iPhone based application) i need to collect a user's timezone so as to show him/her the relevant data.Some of the possibilities that I can think of are : 1.Getting it using user's IP (But what if the user is behind a proxy server) 2.Sending it with request params(But that will require extra param to be attached ...

'scoped' method for Rails 2.X ad Rails 3

Hi, I've got a plugin I'm using for websites using Rails 2.X or Rails 3. In Rails 2.3, I used a lot the 'scoped' method for complex queries : p = Person.scoped({}) p = p.active p = p.with_premium_plan if xyz p etc. But I saw that it changed in Rails 3 : p = Person.scoped etc. So is it normal that I have to do something like that ...

Exclude attribute name prepending in error message

I have a simple internationalization: attributes: user: login: Login errors: template: header: "Errors" body: "" models: user: attributes: login: taken: "The chosen {{attribute}} is already registered" The resulting error message is as follows: Login The chosen Login is already registere...

Is there a way to check the parameters and decide the routes based on the parameters in rails?

I am looking for a way to decide the routes based on a request parameter.For example i want to have route a request to web controller if it has params[:web] and to iPhone if it has params[:iphone]. Is it possible to do so keeping the names of the routes same but routing them to different controllers/actions depending upon the parameter? ...

routing scope problem with form_for (partial)

Trying to route: scope :shortcut do resources :text_elems end Using basic scaffold with form partial *_form.html.erb* <%= form_for(@text_elem, :shortcut => @shortcut) do |f| %> ... Problem is: When I call the edit action, the form html shows as: <form ... action="/25/text_elems/25"> Note: The new action renders the form acti...

How to handle ActionMailer errors ?

Hi, In production, ActionMailer shows following errors, that are displayed in a log: Errno::ECONNREFUSED (Connection refused - connect(2)): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/smtp.rb:551:in `initialize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/smtp.rb:551:i...

Problems using attribute_fu to update a record

I'm using attribute_fu and paperclip to add multiple images to a specific record. This is working great when creating a new record but when I want to add new images to an existing record through a common scaffold update, the images upload but replace the existing images. Any thoughts or advice? ...

Ruby on Rails: remote_form_for to a different controller?

How do I edit a Media but in an Attachment controller? <% remote_form_for(@media, :controller => :attachments, :action => :add_from_disk, :proposal_id => @proposal, :html => { :multipart => true, :id => 'new_media', :onsubmit=>'unsaved_changes = false' } ) do |f| %> currently, its still going to the me...

Ruby on Rails: how do you get the ID of an object instantly after it's been created?

media = Media.new(params[:media]) media.save @attachment.media = Media.find(????) @attachment.save I tried just doing media.id but apparently, that is the media that hasn't been saved to the db yet.... so how do I get the ID? ...

Ruby on Rails: form_for works, but remote_form_for doesn't

<% remote_form_for(@media, :url => url_for(:controller => :attachments, :action => :add_from_disk, :object_id => @object), :html => { :multipart => true, :id => 'new_media', :onsubmit=>'unsaved_changes = false' } ) do |f| %> but if I change the remote_form_for to form_for, I don't get this error: Activ...

Ruby on Rails, Model Joins

Hi Everyone, I have 2 models: class Video < ActiveRecord::Base belongs_to :categories, :foreign_key => "category", :class_name => "Category" end class Category < ActiveRecord::Base has_many :videos end This is fine so far, in my videos controller for the index page I have: def index @videos = Video.all(:joins => :categories) etc, ...

Rails Gem or code to have your rails application respond to email and create a record in the database.

I am creating a ruby on rails application and I want my users to be able to email the application and have the application take in the email and create a issue record in the database. Is there a GEM or Code that can be used to have the rails application get the email and parse out the body and stick it into an issue table. ...