ruby-on-rails

how to search all / wildcard in lucern solr

I'm using RoR + acts_as_solr to query a Solr database. I'm used to using "*" to select all, thanks to MySQL, but that command fires an exception in Solr. Are they other wildcards I can use? Suggestions? Thanks! ...

What's the best background job management library for Rails?

It's been a while since I've last used backgrounding in Rails. I've use backgroundrb and bj before. Is there anything else that manages background tasks better? ...

my rails ApplicationController is having a RoutingError

I am by no means a Ruby developer, but I code HAML for a ruby framework on my localhost. I had originally put a file called vidgirlBox2.flv file and called to it within the HAML, but converted the file to a swf called vidGirl_home.swf . This swf worked. Until I made a simple change to the orginal .fla, and overwrote the vidGirl_home...

Rails 2.3.2 unit test passes when run with normal ruby, fails when run with rake test:units

Hi folks, When creating a record in a unit test, I'm getting an 'ActiveRecord::RecordInvalid' when it's run with rake test:units. I don't get this error when I run the unit test manually with ruby ('ruby unit/blah_test.rb'). I've narrowed the issue down to a validation that exists in my model. It is an inclusion validation which is a...

SQL: how to find a complement to a set with a derived function/value

This one has me stumped, so I'm hoping someone who's smarter than me can help me out. I'm working on a rails project in which I've got a User model which has an association of clock_periods joined to it, having the following partial definition: User has_many :clock_periods #clock_periods has the following properties: #clock_i...

Rails, using time_select on a non active record model

I am trying to use a time_select to input a time into a model that will then perform some calculations. the time_select helper prepares the params that is return so that it can be used in a multi-parameter assignment to an Active Record object. Something like the following Parameters: {"commit"=>"Calculate", "authenticity_token"=>"e...

Rails: How to implement counter caching with self-referential Many to Many via has_many :through

How can I roll my own counter cache for a self-referential many-to-many relationship that uses has_many :through? I need to track the number of citations and references for each article I'm using roughly the code from the answer to this question: class Publication < ActiveRecord::Base has_many :citations has_many :cited_publicatio...

how to add onchange event to select tag in rails

how do i add onchange event here? Framework: rails Database: MySQL am populating the options from the database and tat made me to use options_from_collection_for_select select_tag(:variable,options_from_collection_for_select(:all, :id, :name)) thanks in advance. ...

InstantRails Error

When I try to run InstantRails 2.0 under Vista, which I've extracted to C:\InstantRails, I get the following error: Either Apache or MySQL cannot run because another program is using its port. What do I do here? MySQL server is installed fine. ...

Rails - Permission denied when try to save uploaded file in windows

I'm writing my own file upload in rails. I saw some related questions but it doesn't answer my question. I use File.open ("#{RAILS_ROOT}/public/docs/attachments/#{@file_name}", "wb") {|f| f.write(@temp_file.read)} to write the file on my local machine (OS: Windows XP) instead of saving it in database. I got a Permission denied error o...

Code generation from database with Rails

Hi, I use Qcodo/Qcubed in PHP as PHP5 framework. I am interested in Ruby on Rails, but as my first RoR web app I have to use an existing database (web app with PHP4). I know that RoR is a DSL and everything can be created from your defined doamin, but is it possible to do the reverse engineering? I just need, to start, to generate a ba...

ruby add to array... simple question

I'm sure this is simple but I can't seem to get it: Works: @build1 = Booking.build_booking('2009-06-13',3,2,18314) @build2 = Booking.build_booking('2009-06-13',3,4,18317) @build = @build1 + @build2 What I want to work... #for item in @cart.items do # @build << Booking.build_booking('2009-06-13',3,2,18314) #end Doesn't work either...

How to sort Rails AR.find by number of objects in a has_many relationship

How can I write an AR find query to have the results ordered by the number of records in a has_many association? class User < ActiveRecord::Base has_many :photos end I want to do something like... User.find(:all, :order => photos.count) I realize my find is not valid code. Say I have the following data. User 1, which has 3 phot...

solr query with ruby - need to compare date time

My Lucene/Solr database contains a date column (created_at) that I need to use as a condition in a query. I'm new to RoR and assume that RoR automatically uses its own date object upon anyObject.save, and that Solr in turn reindexes that column in its own way. Regardless, the date is in this format: "2008-06-03 11:15:20" I can write ...

Running RSpec with Ruby 1.9.1/Rails 2.3.2

Hi all, I've been trying to get RSpec running under Ruby 1.9, and my tests just aren't running. Here's my trace: matt@matt-desktop:~/Development/my_app$ sudo rake spec --trace (in /home/matt/Development/my_app) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** I...

Sorting UTF-8 strings in RoR

I am trying to figure out a 'proper' way of sorting UTF-8 strings in Ruby on Rails. In my application, I have a select box that is populated with countries. As my application is localized, each existing locale has a countries.yml file that relates a country's id to the localized name for that country. I can't sort the strings manually i...

Why does my Rails website timeout on Windows XP?

Hi All, YayMyLife.com is my first Rails site. I am using Apache/2.2.8 (Ubuntu) Phusion_Passenger/2.2.2 . The site works fine on Linux/Mac/Phones. However, it does not load on any browser on XP. This behavior is also found on other XP machines. The browser seems to wait for more content and it times out. I have checked headers with Liv...

Multiple has_many_polymorphs in one model

I'm trying to define multiple polymorphic relations (has_many_polymorphs plugin) from a single parent to same children. Note has many viewers Note has many editors Viewers could be either Users or Groups Editors could be either Users or Groups Permission is the association model with note_id, viewer_id, viewer_type, editor_id, editor_ty...

Are there any free services for sending SMS programmatically?

I have a Rails app that needs to send SMS messages to users but does not need to receive messages. Is there a free way to do this programmatically? If so, how free is it - do they charge if you go over a certain number of messages? I know Gmail allows you to send SMS messages now. But I'm not sure if this means you could also send an S...

Rails routing to XML/JSON without views gone mad

I have a mystifying problem. In a very simple Ruby app i have three classes: Drivers, Jobs and Vehicles. All three classes only consist of Id and Name. All three classes have the same #index and #show methods and only render in JSON or XML (this is in fact true for all their CRUD methods, they are identical in everything but name). There...