ruby-on-rails

simple rjs rails question

Here is a extremely simple web page: test.html.erb: <div id="test_div"> Testing 1 2 3 </div> test.rjs: page.visual_effect :highlight, "test_div" Basically, I want my "test_div" to be highlighted when the webpage loads. But for some reason, the div doesn't highlight when I load the webpage. Does anyone know what's going o...

Monitor Multiple Rails Applications

Are there any tools that I can run on my server to monitor multiple rails applications? I need to monitor the number of requests each application receives, how much memory each application is using, how much of the cpu is being used and other stats similar to those. I need to see the stats for each individual rails application. ...

Help in ActiveRecord find with include on conditions

I have a Coach Model which: has_many :qualifications I want to find all coaches whose some attribute_id is nil and they have some qualifications. Something which is like. def requirement legal_coaches = [] coaches = find_all_by_attribute_id(nil) coaches.each do |coach| legal_coaches << coach if coach.qualification...

"gem install bundler --version=0.8.1" doesn't install the bundle executable

When trying to install Bundler 0.8.1 on Ubuntu machine, it install fine but the executable "bundle" is no where to be seen. Other gems install successfully, including their executables. using: "gem install bundler --version=0.8.1" RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-li...

Memory Leak Rails/Delayed Job

What sort of tools are available to monitor memory usage in methods running from delayed_job? I have looked at memorylogic, oink, bleakhouse but they all either seem designed to work with controllers or I am missing something. Any examples of how delayed_job memory leaks (not with the gem itself but the code it is running) are detected ...

how to localize the active record error messages

Hi everyone, I try to figure out how I can localize the error item name in my rails application which appear when a user sign's up with uncorrect datas... I figured out how to override the messages but not the names of the messages like ("password", "login", "email", ...) de: activerecord: errors: models: user: ...

Ruby equivalent of ActiveRecord Group by query

Hi, I want to perform an operation on a array returned from an ActiveRecord query. This is the functionality I would have done on the ActiveRecord directly. Modification.find(:all, :group=>'ref_id,start_date', :order=>'updated_at desc') The above is working fine as expected. But the problem is I cannot perform it directly for some re...

how to convert a hash value returned from a date_select in rails to a Date object?

Hi I have a date_select in my view inside a form, however on submit the value returned is in a hash form like so: {"(1i)"=>"2010", "(2i)"=>"8", "(3i)"=>"16"} how can i convert that in to a Date format in rails so i can use it as a condition when querying the database e.g :condition => {:dates == :some_date_from_date_select}? i tried ...

How are IDs for fixtures generated?

I'm using fixtures to hold all the test data that I have. Each row in my DB has the same ID across several rake db:fixtures:loads. That is nice, because I can create folders in the project, like "people/12345" to hold additional data (files) for the models. I'm interested to know, how are these generated IDs kept constant at every fix...

ActiveRecord where returns ActiveRecord::Relation

u = User.where("name = ?", "mateusz").limit(1) u.class => ActiveRecord::Relation So I cant do smth like u.email and so on. .find does right, returns User object. Is there any chance to get an User object from ActiveRecord::Relation object? ...

rails3 rails.js and jquery catching success and failure of ajax requests

Previously, in rails 2.3.8 i used the prototype-helpers link_to_remote and form_remote_for (amongst others). These had the option :update as follows: link_to_remote "Add to cart", :url => { :action => "add", :id => product.id }, :update => { :success => "cart", :failure => "error" } (an example from the documentation). This exam...

RoR + Jquery not working

Hi! I want use jquery in my project. I know the javascript_include_tag calls the jqeury plugins, but the tag how works in ruby? example <%= javascript_include_tag 'jquery.ui.potato.menu.js' %> <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js' %> <script type="text/javascript"> (function($) ...

Facing lot of problems while using ROR

Hi.. I am new to Ruby on Rails. I have read many article regarding easy installing steps. I installed ruby on windows. After starting the server i got welcome message too. After that if i add a controller I got this message on browser. And also when tried to do a rake db:migrate i get the error saying mysql gem is missing. I have inst...

function ts_rank_cd(text, tsquery) does not exist

i'm using full text search supported by postgres, i installed acts_as_tsearch plugin and it works successfully, but when i tried it later i found an error ntimeError: ERROR C42883 Mfunction ts_rank_cd(text, tsquery) does not exist HNo function matches the given name and argument types. You might need to add explicit type any ideas ?? ...

Is there an ActiveScaffold equivalent for Django?

A while ago I created a frontend for a database using RoR and ActiveScaffold. ActiveScaffold let me easily create lots of the features I needed: Read Only Access, Sexy Interface, Sorting, Advanced Search, Pagination etc. I would now like to do the same thing in Django. Is there any equivalent to ActiveScaffold for Django? Do I need to u...

Cannot expire cached fragment by default methods in Ruby on Rails + Devise

I'm using Devise as authenticating solution in Rails and I have a cached fragment :recent_users. I want this fragment to expire when a new user is registered, changed or removed, so I put in my(manually created) users_controller.rb class UsersController < ApplicationController cache_sweeper :user_sweeper, :only => [:create, :updat...

Fetching people without a registration for a specific event

I'm trying to fetch all people without a registration for a specific event. My models are Person, Event and Registration. In the MySQL table it would add an entry to the registrations table with the person.id and event.id (plus comment and a "status" - 1 for registration, 2 for deregistration). Now, I'm trying to get all people which ...

Select-locking in Rails with MySQL

Looking for a best-practice advice: Let's suppose I have a Account object with limit attribute. Each day there can be n Payments, with sum of their amounts up to the account limit. When creating a new payment, it checks to see if it's amount + amounts of other payments of the day are still within the account limit, and either saves the ...

Understanding MVC architecture as non-MVC-developer

Hi folks, I have a problem with the understanding MVC architecture. It's not that I don't know anything about MVC. Everything makes sense to me in a MVC architecture but if I want to start to develop my app in an MVC architecture I'm stuck. Basically there are a lot ways to do what you want in the programming world but I want to do it ...

rails3 routes issue

I have following routes. pota.resources :on_k, :as => ':klass', :path_prefix => 'pota/klass', :controller => 'main' When I do rake routes this is what I get for show method: pota_on_k GET /pota/klass/:klass/:id(.:format) {:action=>"show", :controller=>...