ruby-on-rails

Rails I18n accepts_nested_attributes_for and error_messages_for

I've got two models class SurveyResponse has_many :answers, :class_name => SurveyResponseAnswer.name accepts_nested_attributes_for :answers end class SurveyResponseAnswer belongs_to :survey_response validates_presence_of :answer_text end In my nested form if validation fails I get this error displayed on the screen: "answers...

How to set ActiveModel::Base.include_root_in_json to false?

I'm using Rails 3 w/ Mongoid, (so no ActiveRecord). Mongoid uses ActiveModel's "to_json" method, and by default that method includes the root object in the JSON (which I don't want). I've tried putting this in an initializer: ActiveModel::Base.include_root_in_json = false But get the error uninitialized constant ActiveModel::Base ...

With the attachment_fu rails plugin, is there any way to delete files uploaded to Amazon S3?

Let's say I'm using attachment_fu to attach profile pics to user profiles in a system, with Amazon S3 used as the actual file storage. When users upload new profile pics, I'd like to replace the attached file with the new one. I can do this within my database (i.e. the file metadata) easily, but attachment_fu doesn't seem to provide meth...

My jquery AJAX POST requests works without sending an Authenticity Token (Rails)

Hi all, Is there any provisions in rails that would allow all AJAX POST requests from the site to pass without an authenticity_token? I have a Jquery POST ajax call that calls a controller method, but I did not put any authenticity code in it and yet the call succeeds. My ApplicationController does have 'request_forgery_protection' an...

How to install a forked gem of LinkedIn?

I want to use the LinkedIn gem But not the one that I get when I type sudo gem install linkedin I want a specific one that somehow has done patches to. It is a fork of the original which is: http://github.com/jbasdf/linkedin I tried: sudo gem install jbasdf-linkedin But not succeed. Any ideas? Thanks. ...

log analysis for rails

i have a rails app which makes heavy use of activeresource and httparty to make api calls. Is there any library/extension to log the requests and parse them, so that log analysis becomes easier and automated. RailsLogAnalyser is good but what about extra calls, what are the conventions? Something like a opensource/self-hosted alte...

[rails] user's account backup and restore

Hi everyone, I am currently working on a project and i would like my users to be able to backup/restore theirs accounts. I am looking for a rails plugin/gem that would easily do that, ie : current_user.backup() => backup_file current_user.restore(backup_file) => database import/replace I don't know if my questi...

How do I use a named_scope to filter records in my model

I have a model "Product" with a "description" field. Now I want to have a link in the index page that when clicked will show all products where the description is blank (empty). In the model I have defined a named_scope like this named_scope :no_description, :conditions => { :description => "" } I have checked that the named_sco...

'' Not a valid unicode character, but in the unicode character set?

Short story: I can't get an entity like '𠂉' to store in a MySQL database, either by using a text field in a Ruby on Rails app (with default UTF-8 encoding) or by inputting it directly with a MySQL GUI app. As far as I can tell, all Chinese characters and radicals can be entered into the database without problem, but not these rarely typ...

How to remove a specific file in Rails public folder?

User in my web app are able to upload file. I use Paperclip to handle file attachment issue. Is there any method if I would like to remove any specific user-uploaded file programmatically? ...

Restful_authentication without activation but with suspension.

Is there a way to configure restful_authentication such that you can get admin functionality e.g. suspension and purging accounts WITHOUT having to activate accounts via email? ...

Rails i18n: Can I turn off "translation missing" errors?

I have a multi-tenant application and I'm experimenting with using the i18n gem to allow each of our clients to customize the system to their liking, changing the text on various pages, customizing emails, and so forth. Admittedly, I'm not using i18n as it was intended to be used, since I'm not actually translating different "languages",...

How to simulate a close() in facebox

Hi, I am using facebox popup in one of my pages. I am having a button in the popup dialog. When I click that button the facebox popup should close (the same way it closes when we press outside the popup). How to do that? Also, I am doing some Ajax stuff when that button is being pressed so I cannot override the onClick event. ...

How to import contacts from Gmail, Yahoo, Aol, Hotmail, msn, etc..

Hi, I am trying to import contact list in my Ruby On Rails application. I got succeed using sailthru API, but the problem is, it replies empty result for aol, msn, hotmail. I also tried rails gem 'contacts', that is also not replying for all(only answers for gmail, yahoo, aol). :( Thanks to reply in advance, Alpesh Modi ...

Ruby On Rails on Windows - Linux VM or dual boot

I am a windows developer currently getting into Rails. While you can develop on RoR Windows, it's not the ideal experience. Things are glitchy and running cucumber tests are painfully slow. So, would I be able to have a decent dev experience running Linux in a VM for doing RoR development, or should I bite the bullet and just do a dual ...

Using colon syntax and variables in Sass

I am still using the old colon syntax (I prefer it more than the bracket syntax) and this particular code: a.button-link +box($main-color) +border-radius(5px) :background :color $main-color :color #fff :padding 5px generates a warning like so: DEPRECATION WARNING: On line 12, character 3 of '/Users/eumir/rail...

Saving an ActiveRecord non-transactionally.

My application accepts file uploads, with some metadata being stored in the DB, and the file itself on the file system. I am trying to make the metadata visible in the application before the file upload and post-processing are finished, but because saves are transactional, I have had no success. I have tried the callbacks and calling c...

Rails Functional test on a custom route

I have the following routes in my app: GET /admin/comments(.:format) {:controller=>"admin/comments", :action=>"index"} admin_comments POST /admin/comments(.:format) {:controller=>"admin/comments", :action=>"create"} new_admin_comment GET /admin/comments/new(.:fo...

Problem with map.root

When i set map.root :controller => "welcome", I get the standard rails page, rather than the welcome page. I have deleted public/index.html and "localhost:3000/welcome" works. Any ideas? ...

System calls are terminating

Hello. I am running rake task(which must be being launched for ~24 hours) but it stops in unexpected time. STRERR is empty. The code which runs the task: @bucket = Bucket.find(params[:id]) cmd = "#{`which rake`.chomp} bucket:generate[#{@bucket.id}] --trace 2>&1 > #{Rails.root}/log/bucket-#{@network.id}.log &" # 2> #{Rails.root}/log/buck...