ruby-on-rails

Uninitialized constant Encoding with sqlite3-ruby on windows

On a new machine, installed ruby with the 1-click installer for windows. Installed rails 2.3.2 and all associated gems, then I installed the sqlite3 binaries (into the c:\ruby\bin folder). Lastly I did gem install sqlite3-ruby -v=1.2.3 (which is apparently the latest version that works with windows) This error happens when I run rake ...

Rails in-process background services

Is there a background job framework for rails kinda like backgroundrb that works in the mongrel process? One could use it in small utility web applications to make application start easier and save memory. ...

Is Rails' protect_from_forgery really useful?

I'm asking this because I feel that it's making my life overly complicated when I start communicating with rails using ajax or flash. I know it's nice to protect against CSRF, but couldn't I just check the referer or something instead? ...

time_ago_in_words and localize

Is it possible to use time_ago_in_words with i18n.locale? how? thanks ...

ERB tag within link_to_function javacript call

I need to dynamically set which id a javascript call uses, as I have multiples rendered on each page, I'm trying to use <p id="add_rider_link_section_<%= section.id %>"><%= link_to_function("Add a Rider", "Element.remove('add_rider_link_section_' + <%= section.id %> + '' ); Element.show('add_rider')") %></p> It's failing on "Element....

Passenger + Rails App Not Loading

So I've just tried to migrate my first rails application from the development environment on my laptop to my hosted environment(just another machine that is externally facing), but I seem to keep getting errors with apache/passenger trying to run my app. Basically I've configured apache and passenger correctly in that the main site sti...

I'm searching for a Grails-Plugin to attach images to a domain class

Hi, i am quite new to Grails and on the lookout for a plugin to attach files (images) to a model. something like a uploaded avatar-picture for a user. in Ruby on Rails i used the fantastic Paperclip plugin. Someting like that would be absolute awesome. Thanks for your help. ...

RoR show elements in two columns

how can i split elements of a model into two equally sized pieces so that i can show them in two columns? i have this: element 1 element 2 element 3 element 4 element 5 and i want this: element 1 element 4 element 2 element 5 element 3 split() unfortunately removes the middle element. ...

Rails polymorphic relationship in the other direction

Having set up my polymorphic relationship like so: class Review < ActiveRecord::Base belongs_to :reviewable, :polymorphic => true belongs_to :user end class Wine < ActiveRecord::Base has_many :reviews, :as => :reviewable end class Beer < ActiveRecord::Base has_many :reviews, :as => :reviewable end I can do Wine.last.reviews ...

Advantages and disadvantages of Ruby on Rails polymorphic relationships.

What advantages and disadvantages do you know of Ruby on Rails polymorphic relationships. ...

Guidance on testing extremely long form with 20+ required fields, using Rspec / Cucumber

Hi all, Just wanted to get some opinions on how to go about testing an extremely long form with 20+ required fields. It seems like my Cucumber scenario could be like 25 lines long if I tried to describe every field that need to be filled in (something like "And I fill in "Name:" with blah, And I fill in "Address" with foo, etc.). If I ...

How could I pass a database run-time parameter in ruby on rails?

I need to set a run-time parameter in postgresql. It is "SET DATESTYLE TO PostgreSQL,European;". Where can I pass that in a Rails Application? ...

ruby Online Quote app

I am trying to build an online quote app for roofing. I have a controller called Cost that has squarecost and squaresell. There are other models and controllers for gable, shingle, ridgevent and more with similar fields. These additional models and controllers are the add ons for the quote. Ideally, sales person would create a new q...

rails stack level too deep?

Im trying to implement roles feature to my app that already has authlogic working... Im following this tutorial but now Im getting an error "stack level too deep" when I try to run my app... SystemStackError in Users#new Showing app/views/users/_form.erb where line #2 raised: stack level too deep Extracted source (around line #2): ...

How to get integer index from named order

This might be really obvious but I can't find the answer. How do you get the integer index from named order, like: { :first => 0, :second => 1, :third => 2, :fourth => 3 } Is there something built in to Ruby or Rails that does this? Thanks. Update Thanks for all your responses. Here's the solution I went with: def index_for(posi...

Is there a questions-and-answers rails plugin?

I am working on a project that has a questions-and-answers section. My client - and me of course - looks highly at stackoverflow and how it made questions-and-answers so great. My question is, Are there any plugins/apis that I can use in my Rails application to provide a questions-and-answers section without having to build it from scra...

Multiple Markers on Google Map (Fails to display over 10 markers) - Ruby on Rails Environment YM4R Plugin

Hi, I have the following issue. I have a google map (using YM4r + Geokit) within Ruby on Rails, anyhow, i basically have an array of markers which are populated in the following manner @shops.each do |sto| markers << GMarker.new (....) end They are definitely being stored fine as under 10 markers they are displayed just fine. Th...

Help with roles in rails

Im trying to use this approach. My app is a cms. I have admins, editors, and subscribers. for a blog with categories... its an experimental project so I cant use wordpress or whatever. Admins should be able to do anything, editors should allow be allowed to create/edit/delete content for the category they belong to and suscribers are ju...

RoR / Ruby delete nil elements from nested array

in a previous question i asked how to split an array into two equal pieces in ruby on rails. this is how i did it: >> a = [1,2,3,4,5] => [1, 2, 3, 4, 5] >> a.in_groups_of( (a.size/2.0).ceil ) if a.size > 0 => [[1, 2, 3], [4, 5, nil]] now i've got a nested array that contains nil elements if the size of the array is odd. how can i remo...

mysql missing field after running rails db migration

i have a rails migration: >> cat db/migrate/20091126031039_create_cards.rb class CreateCards < ActiveRecord::Migration def self.up create_table :cards do |t| t.string :number_hash t.int :number t.string :name t.string :type t.string :expiration t.int :sec_code t.timestamps end end ...