ruby-on-rails

How to interact with a Users webcam & inbuilt microphone using Ruby / Rails?

Hi All, Not sure how to frame this one, so here goes... I have a need to develop an application which allows my boss to post a series of questions that will be answered by various consultants around the world, each question will have a time limit in which it can be answered e.g. 3 minutes. Here is the problem, the users answering the ...

in-place edit in Rails 3

There are a few options for editing a model in-place while in the Show page, i.e. without having to load a form in the Edit page. For example, see http://www.ruby-toolbox.com/categories/rails_in_place_editing.html. Has anyone had any experience using any of these options (or others) in Rails 3? Any pointers or advice? In my case, I hav...

Using ActionMailer in a Rails Plugin

I'm trying to create my first Rails plugin and am having some troubles leveraging ActionMailer in it. The plugin just collects user feedback and emails it off a given address so in terms of functionality it's not too complicated... All the functionality was working perfectly in my original application until I decided to pluginise this s...

assert_equal says <0.15> expected but was <0.15>, but only if the method computes 0.15 in a certain way

So for this model method: def tax_rate tax_rate = 0.0 tax_rate += STATE_TAX if state_taxable? #STATE_TAX = 0.1 tax_rate += IMPORT_TAX if imported? #IMPORT_TAX = 0.05 tax_rate end This test fails: @item.update_attributes({:state_taxable => true, :imported => true, :price ...

validates_inclusion_of :in => [true, false] is allowing Strings and Fixnums

I have this validation in my model: validates_inclusion_of :imported, :in => [true, false] but still allows Strings and Fixnums. This Shoulda macro returns 2 failures: should_not_allow_values_for :imported, "blah", 42 and I've checked that the macro isn't at fault by doing this in a test: @item.imported = 42 assert [email protected] ...

Is it possible to group by hour/minute/quarter hour directly in ActiveRecord/Rails?

I want to group my data by the hour/day possibly even to the quarter hour. Can I do this directly in ActiveRecord or should I just grab all the data and do the aggregation manually? Table "Checkin": Time NumBikes ChangeBikes 09:00 5 5 09:05 6 1 09:10 10 4 10:00 6 4 10:05 8 ...

Thinking Sphinx: is it possible to use complex logic with attributes?

Hi, This question is in a way related to this other question: http://stackoverflow.com/questions/869733/sphinx-filters-can-i-have-an-or-between-filters-attributes It seems to me that sphinx now has support for OR logic to filter with attributes, but there is no way to use that feature through thinking sphinx. Is it possible to use a...

Deploy a rails app using MongoDB, Mongomapper in production

Hello, We are planning to deploy a Rails 2.3.8 application which uses MongoDB, on our website. Our present web hosting provider is hostgator and they do not provide support for mongodb. So, what are the best/cheap hosting companies out there where I can have full stack of Ruby on Rails and MongoDB? We are looking for cheapest hosting ...

Text Area helper , how to set maxlength.

Text Area helper , how i set the maximum length of string to 100. Is there is any max length attribute in text-area helper in ROR. Code will help me.Thanks ...

How do I use the 'map' method in an ActiveRecord class method?

Not sure on my Ruby syntax here. I want to define a method that I can call like this: client.invoices.average_turnaround. So my average_turnaround method needs to work with a collection of ActiveRecord objects. Here's my code thus far: class Invoice < ActiveRecord::Base ... def self.average_turnaround return self.map(&:turnaro...

Password encryption problem in Rails Devise gem

I am now currently changed to use the Gem Devise for user authentication. But I don't know how to match the encryption! I knew that we could write a new encryptor and assign it in initializers, but the point is the encryptor accepts 4 arguments only (password, stretches, salt, pepper). But in my case, I do included the user's email and ...

Find Stuff (but not in production)

Using the tutorial "Find Stuff (quick and Dirty)" in "Advance Rails Recipes", I can find stuff in the development environment but not in the production environment. NoMethodError: undefined method `searchable_by' I have this code in "lib/searchable.rb" module Searchable def searchable_by(*_column_names) @search_columns = [] ...

Ruby on Rails: Thinking Sphinx Delayed Delta Isn't Working by Following Documentation

Following the delayed delta guide here (at the bottom) I did everything that the documentation asked. After I did all of the steps there, I ran a rake ts:rebuild and a rake ts:dd and attempted to load my app (development). When it loads, I get: NameError in CustomersController#index uninitialized constant ThinkingSphinx::Deltas::Delaye...

Active Resource Nested Routes

Im currently trying to integrate with a third party API using active resource. Ive completed a large amount of the work but am struggling with a single nested resource. /company/:company_id/users/:id I can retrieve the users from the company using API::Company.find(124343).users but any subsequent changes to a user will not save. ...

Rails simple constants and select options.

I have a simple constant called "subjects" in my model Inquire.rb and I like to know if there is a simple way to use the position in the Ruby array rather than making a hash from it with ids or some more complicated array. Can I do this? i.e. instead of to_s as it currently does for the value in the select, I would want an integer indi...

Rails i18n default value

My current Application has a complete english translation, but i can't make sure additional languages are fully implemented, too. This results into translation_missing warnings or rather strings like "de, install, steps, language" Is there a way to tell rails to use the english translation in case there is no (in this example) german o...

Large File Uploads.

Do large file uploads block an applications request/response cycle? I have an app that allows users to upload multiple large files (images in particular). These files are stored on a remote host. I cannot use async background jobs to upload these images as these have to be immediately accessible to the user once the upload finishes. How ...

Ruby equivalents for PHP's magic methods __call, __get and __set

Hi, I am pretty sure that Ruby has these (equivalents for __call, _get and _set), because otherwise how find_by would work in Rails? Maybe someone could give a quick example of how to define methods that act same as find_by? Thanks ...

Why does ActiveRecord only sometimes provide reciprocal associations automatically?

When working with activerecord I notice that while constructing associations, the reciprocal association is provided automatically only if the reciprocal model has already been saved. If it has not yet been saved, this reciprocal association must be defined manually. I am wondering if this is intentional or a bug, since the only differ...

access to hash through an variable in ruby on rails

Hello I have following problem. I have a hash filled with the html parameters (params): Parameters: "info"=>{"parameter2"=>{"r1"=>"aa", "r2"=>"bb", "r3"=>"cc", "r4"=>"dd", "r5"=>"ee"} You can access this values like this: <%= params[:info][:parameter2][:r1] %> --> it works fine But I have a loop, and want to access these values ...