ruby-on-rails

I'm getting "undefined method `abstract_class?' for Object:Class" for count_by_sql

I'm getting the error: "undefined method `abstract_class?' for Object:Class" on a count_by_sql as below: my_count = ActiveRecord::Base.count_by_sql(["SELECT widgets FROM wodgets WHERE colour = ? LIMIT 1", my_favourite_colour]) I've just been upgrading from Rails 2.2.2 to 2.3.4 and it used to work before. ...

Good practices for Integration Tests for my rails app external endpoints?

I'll keep it short, I've got a rails app which communicate with other apps, some using SOAP (non-rails apps of course...) and others with REST. I'm making integration tests to ensure that my endpoint wrapper classes have correct mappings and setup. However, they are executed by default by rake test which makes it slow and fragile. I wish...

belongs_to has_one structure

I have an application which has the following characteristics There are Clubs Each Club has Teams Each Team has Players I have a users table. The user table basically contains the username and password for the club manager, team manager and the player to login to the system. How should I structure the models and the tables? I plan...

Simple solution for blog alongside ruby on rails app on heroku

I am developing a rails app which I am planning to host on heroku but I would also like to include a blog at http://mydomain.com/blog. I need a simple, single-author soultion with tags, commenting (I was thinking of disqus for this) and the ability to add images. What are my options apart from rolling my own? ...

How to port `error_messages_for` from Ruby erb to Java JSP/JSTL?

How would you port this front-end logic from erb to jsp/jstl? <%= error_messages_for :foo %> Is there any Java library that does something similar? ...

Ruby on Rails: How do you make link_to_unless_current work with parameters?

I'm trying to do something like so: link_to_unless_current "Inbox", messages_path(:inbox => true) But, it seems that link_to_unless_current only works if I go to "http://localhost/messages" and not "http://localhost/messages?inbox=true" (i.e. it doesn't give a link for the latter which is correct, but it does for the former which is i...

How do I create dynamic CSS in Rails?

Hi, what is the best/most efficient way of creating dynamic CSS with Rails. I am developing an admin area on a site, where I would like a user to be able to customize the style of their profiles(Colour mostly), which will also be saved. Would you just embed ruby script in the css file? Would you need to change the file extension from c...

How do you simulate a Rails error flash in jsp?

Is there a jsp/jstl equivalent of this Rails error flash? <%- flash.each do |name, msg| -%> <%= content_tag :div, msg, :id => "flash_#{name}" %> <%- end -%> I've been looking for a pre-built solution that is as simple as this Rails idiom. ...

Using blocks to define abilities in CanCan raises an exception

I am using Ryan Bate's CanCan gem to define abilities and some basic functionality is failing. I have a Product model and Products controller where my index action looks like this: def index @req_host_w_port = request.host_with_port @products = Product.accessible_by(current_ability, :index) end I get an error when I try to ret...

Rails engines depending application code?

We have what I suspect is an unusual setup. We have a Rails app which is something we sell to customers. We also package up bundles of business features into optional addons that the clients can purchase according to their needs. We have done these as Rails plugins/engines to keep them nicely separated. This forces the unusual requ...

Thinking Sphinx delta indexing - delta index not getting updated

I have delta indexing setup for thinking sphinx on one of my models. When ever a record gets updated, the delta is being set to True, but I don't see the index getting updated with the changes made to the record. I have my sphinx configuration files updated with the delta property changes. Any idea why the delta indexing is not getting t...

zlib library problem related with Virtual Box version

Hi to all, on the last days I had a really annoying problem, that is just now solved, but I'll hope that some of you experienced it and figured out a solution for that. I created and installed Ubuntu 10.04 on Virtualbox 3.2.0 (installed under Win7-32 bits). On this VM was installed and configured rvm, ruby 1.8.7 and some gems. When trie...

Nested form and link_to_function

Hi everyone! I've got a nested form like this : <% form_for setup_training(@training), :url => admin_trainings_path, :html => { :class => :form } do |f| -%> <!-- begin of form --> <!-- content of :partial => "day_form" --> <% f.fields_for :days do |days_form| %> <%= render :partial => "admin/days/form_inner", :locals => { :f => da...

How to solve an "uninitialized constant Cucumber" error?

Hi! I'm trying to get one open source application up and running. But unfortunately I'm getting the following error: rake aborted! uninitialized constant Cucumber I have already tried installing Cucumber with the following line. That dowloaded the ".\vendor\plugins\cucumber\" folder, but that error remains the same. script/plugin ...

Unable to load driver 'ODBC'

Trying to load ODBC in my Rails app (I'm on Linux, FreeBSD 7.3-STABLE using rb-odbc, unixODBC, and FreeTDS to connect to MSSql) but I'm getting this error: Trace can be found here: http://gist.github.com/547759 Anyone have any glaring ideas? Thanks! ...

How does Ruby on Rails handle "Select count(*) from products group by category"?

Say if there is a table with fields Products -------- ID CategoryID Name Price ... etc How can Ruby on Rails give a table that returns select count(*) from products group by categoryID which is to show how many products in each category? How will the result be like, as opposed to Products.find(:all) which is an array of Product ...

wrong # of arguments(0 for 1)

Hello all, Here is my Test model code: require 'rubygems' require 'composite_primary_keys' class VamTest < ActiveRecord::Base set_table_name 'tests' set_primary_keys :service, :host end This is the stacktrace I get when I run the following: >> VamTest.all VamTest.all ArgumentError: wrong # of arguments(0 for 1) from C:/jruby...

How to remove rvm (ruby version manager) from my system?

Hello guys. How can I remove rvm (ruby version manager) from my system? ...

What does this mean ? >> ActionController::InvalidAuthenticityToken

I was curious what that meant in general. But here is the specifics.. I'm doing a sortable jquery project, that touches this rails action : def update_order params[:media].each_with_index do |id, index| media = @organization.media.find(id) media.do_not_touch = true media.update_attribute('position', index+1) end if par...

RoR render partial with javascript

Hi, I am having trouble rendering a partial with javascript. I need the javascript to be part of the document, but for some reason when inspecting the document the javascript is not there. Is there a way to render a partial with javascript so it is part of the document? ...