ruby-on-rails

Rails 3 - form_for and success/failure callbacks

I've upgraded my app to Rails 3, and in the process I replaced form_remote_tag with form_for. I'm trying to set success and failure callbacks but they aren't working: :html => { :success => 'onFormSuccess(request)', :failure => 'onFormFailure(request)' } Does this not work with form_for? ...

Could Rails 3.0's "gem install rails" or "bundle install" install a sqlite3.dll as well?

Rails 3.0 installation on Windows was almost seamless, except it'd still just say sqlite3.dll is missing and I think the solution is to find it and then put into one of your path such as c:\ruby192\bin or c:\windows ? Supposedly, can gem install or bundle install actually put it somewhere that is usable? ...

XSendFile can't stat file if on windows samba share?

Hello, I am having trouble getting apache to serve a file through the XSendFile when it is in a directory mounted with samba. To give a little background: I have a Ruby on Rails app that is slowly replacing an ASP.NET application, and I have it running on a linux server running apache2 and passenger. The Windows machine that is running...

rspec asserting encrypted password not plain text

How would I write a test in rspec to ensure passwords are not stored as plain text in my Ruby on Rails application? I don't really care about the implementation yet as I don't know exactly what plugin or how I am going to write the password encryption (there are lots of examples). I just want a failing test that's independent of the ...

Ruby: What is the easiest way to remove the first element from an array?

Lets say I have an array [0, 132, 432, 342, 234] What is the easiest way to get rid of the first element? (0) ...

Check if Javascript is available and redirect to another page

In my rails site, i require javascript on all the pages. If it is not enabled, every page will fail. What I want to do is, if there is no javascript enabled, I want to redirect them to another static page - asking users to enable the javascript first. I want this to happen for all the pages. Is it possible ? I have tried to put code in...

ajax in Rails playtime

I read the rails book about build Store" Add a date and time to the sidebar. It doesn’t have to update: just show the value at the time the page was displayed". There is an answer from the page which the book provided. One of these from Ken is : using ajax to test this out so, in my index page I added: <div id="time"> <%= @current_...

Rails, same view, different controllers

map.resources :persons map.resources :people class Persons_controller < ApplicationController::Base #the whole logic for the controller end class People_controller < PersonsController #nothing special there end How I can use the views from /app/views/persons/ when I access my app from http://mydomain.com/people/1 ? I get an err...

Ruby on Rails: Is it possible to DRY up routes?

I have the nested resource "resources :comments" added to a lot of parent resources as follows (using Rails 3): resources :cusines do resources :comments end resources :recipes do resources :comments end resources :chefs do resources :comments end resources :countries do resources :comments end etc., etc., etc. Since I hav...

Rails 3 is out and now there is no documentation online for 2.3.x

I thought I would start a wiki for links to old rails documentation since "Rails 3 is greatest thing since sliced bread" :). Rails 3 IS awesome, but I'm not moving to it yet. I can't find docs for 2.3.5 or 2.3.8 anywhere. The closest I can find to what I need is this: http://railsbrain.com/api/rails-2.3.2/doc/index.html +1 to anyone wh...

Google App Engine with JRuby - can someone provide an overview of appengine-jruby, warble etc?

Hello there! I'm getting myself confused as to how to get a JRuby app cranking on App Engine. I know that you can get started using the appengine-jruby "gem" (Note: I'm a Java programmer, so this is all completely new to me). I've also seen some talk about Warbler, and am getting the impression that I could probably use Warbler someho...

How do I set MySQL as the default database in Rails 3?

I started using Rails 2 last April but stopped this June because I thought learning it when Rails 3 was released would be more practical since a lot of it was completely refactored and restructured. I used to work with Ubuntu 10.04 (with SQLite3 as the default db) but now I'm using Windows 7 and MySQL 5. I already installed the gem adapt...

Rails 3 and undo last action button

Which solution would you prefer to use with Rails 3 in order to provide gmail like undo option instead of confirmation popups? I would like to allow user to undo last action, which would then revert the changes in tables made by that action. So far I was trying to get things done using Memento gem. Its not ideal, but things worked. Th...

ruby: how to access properties specified in config files inside my models and controllers

As title says, I have a yaml file with values like development: email:[email protected] test: email:[email protected] production: [email protected] and i load this file in an rb file located under "initializers" directory as SpecFile = YAML.load_file("#{RAILS_ROOT}/config/application.yml") Question is, I need to access these values in my model...

Rails yield - content_for problem

Hi All, I have the following requirement. Ex: There is a transaction table where it has columns say, transaction_name and amount. I want to loop through the transactions and display their details (transaction_name and amount) and finally I want to display the total amount (sum of all the amounts) in the head (before the loop) section...

Rails Multiform structure seems a bit off

Ok so I am having a problem with doing multiple forms in rails. here is the code below Models class Profile < ActiveRecord::Base belongs_to :user has_attached_file :avatar, :styles => { :medium => "134x137>", :thumb => "111x111>", :tiny => "32x38>" } validates_attachment_content_type :avatar, :content_type => ['image/pjpeg','im...

How to set a before_filter for every controller bar one?

In Ruby on Rails, I would like to add a before_filter to every controller except for one. Currently I have in ApplicationController: before_filter :authenticate Is there a way to apply this rule inside ApplicationController rather than adding before_filter :authenticate in every controller except the public controller? ...

How can I retrieve updated records in real-time? (push notifications?)

Hello, I'm trying to create a ruby on rails ecommerce application, where potential customers will be able to place an order and the store owner will be able to receive the order in real-time. The finalized order will be recorded into the database (at the moment SQLite), and the storeowner will have a browser window open, where the new or...

Rails "moments ago" instead of created date?

Hi Everyone, Currently I have the following in my helper: def created_today k if k.created_at.to_date == Date.today then content_tag(:span, 'Today', :class => "todayhighlight") else k.created_at.to_s(:kasecreated) end end What I would like to do is replace TODAY with MOMENTS AGO if the created_at time is within th...

[rails] [acts-as-taggable-on] update owner tags via form

I would like to uniquely use owner tags in my app. My problem is that when I create / update a post via a form I only have :tag_list: <%= f.text_field :tag_list %> which only updates the tags for the post but has no owner. If I user :all_tags_list <%= f.text_field :all_tags_list %> it doesn't know the attribute on create / update. I ...