ruby-on-rails

What version of ruby?

What the current stable recommended release of Ruby? 1.8.7 or 1.9.x? I will be deploying a rails(v 2.3.8) app & was wondering what version of ruby should I be using. My deployment environment is Ubuntu/Apache/passenger (mod_rails) RubyOnRails.org website says - "We recommend Ruby 1.8.7 for use with Rails" I want to know - whats the re...

Quick Nokogiri/Ruby question

Hello, I have a quick parsing question. I have a file with the following structure <admin> <sampleName>Willow oak leaf</sampleName> <sampleDescription comment="Total genes"> <cvParam cvLabel="Bob" accession="123" name="Oak" /> </sampleDescription> </admin> I'm trying to get out the text "Total genes" after the sampleDes...

Best way to implement Stackoverflow-style reputation

I'm implementing a Stackoverflow-like reputation system on my rap lyrics explanation site, Rap Genius: Good explanation: +10 Bad explanation: -1 Have the most explanations on a song: +30 My question is how to implement this. Specifically, I'm trying to decide whether I should create a table of reputation_events to aid in reputation r...

rails 2.3.5 - bug makes ActiveRecord::Base.configurations false. How do I track it down?

I've been updating my user test server and now suddenly I got an error every time I invoke rake with anything database-related. Sample error: rake db:drop RAILS_ENV='production' --trace rake aborted! undefined method `[]' for false:FalseClass /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:96 Here's line 96 of...

Explain Iterator Syntax on Ruby on Rails

I started learning Ruby on Rails and found myself confounded by the syntax, so I had to read about somet of the Ruby syntax. I learned the syntax from http://www.cs.auckland.ac.nz/references/ruby/doc_bundle/Manual/man-1.4/syntax.html: method_call do [`|' expr...`|'] expr...end They call it an Iterator. I understand an iterator runs th...

Can I use cassandra with heroku?

Is it possible to use cassandra with heroku? ...

Is there an equivalent of <<<EOD in Ruby/Rails?

In PHP, the following would allow me to create a string without having to escape quotes.. $string = <<<EOD ',. whatever <"",' EOD; echo $string; Is there anything similar to it in Ruby/Rails? ...

Access CanCan's `can?` method from a model

You can get the current_user's permissions from a view or controller using can? in this fashion: <% if can? :update, @article %> <%= link_to "Edit", edit_article_path(@article) %> <% end %> How can I access this functionality from a model using this syntax: user.can?(:update, @article) ...

How do I translate "File.open" to be S3 compatible?

I have this line.. @organization.search_image = File.open(@photo.photo.path(:original)) Except that 's looking for something local, and all my photos are on S3 now. How would I translate that to opening a file on S3? ...

Paperclip running multiple times on each page

I am using paperclip to save photos to my users' profiles. Rails is saving the paperclip attachments multiple times every time a page loads. Any ideas on why this is happening? ...

Preparing XML Data for Chart Library

I am using a flash chart library that takes an xml file/string as input. The xml file is generated using a xml.builder file, but I am not sure the generated xml file is actually being found. If there is a (name).xml.builder file and a (name).html.erb file, does that mean both an html/xml file is generated, when format.html and format...

Restrict respond_to to JSON only, rails 2.xx

I need to restrict respond_to to JSON only, because I am constructing a web service that will provide JSON formatted output only. How do I do this? ...

Rails: creating RESTful web services with XML and JSON

Hi, I'm curious about the best practice in creating web services which support both XML and JSON output. At the moment, my service is very XML oriented (see below), but I want to add JSON support. Here's one example: def create render_authentication_error and return if !@user render_parameter_not_found_error("item") and...

What are the main advantages Ruby on Rails has over other web programming languages?

Why would I choose Ruby on Rails instead of PHP or ASP.NET when starting a new middle-sized project that has no restrictions? (not limited by hardware/operating system/memory/etc) ...

NoMethodError in Ruby on Rails

Hi All, I've encountered the following error while trying to create a blogging application. Any ideas why? NoMethodError in Articles#show Showing app/views/articles/show.html.erb where line #1 raised: undefined method `title' for []:Array Extracted source (around line #1): 1: <h2><%= @article.title %></h2> 2: 3: <% if @article...

Disordering of a has_many association with belongs_to reference into the has_many

My data resembles this: class Team < ActiveRecord::Base has_many :persons belongs_to :leader, :class_name => "Person" end class Person < ActiveRecord::Base belongs_to :team end I create the Team like this: @team = Team.new for (each new person as p) new_person = @team.persons.build new_person.name = p.name if...

acts_as_taggable undefined method 'each' error

I am trying to use acts_as_taggable plugin to include tag functionality in my ruby on rails application. I have attached the code. I have installed the plugin and also run the migrations.I am getting the following error. undefined method `each' for "value of the parameter":String Code location.rb - location table has name, tags(this ...

Rails: best way to generate a form dynamically

I am creating an application where I want to add metadata about table fields from an enterprise system. I have a table_structure model which retrieves a table definition information like: table_name field_name Field_type field_length ... a particular field may exist in multiple tables like: tableA fieldX tableB fieldX regardless ...

Problem with forgot password and authlogic

Hey all I'm having a few problems with the forgot password system from this tutorial. My application uses Authlogic for the authentication system and it works perfectly for user login/logout and registrations. However after I followed that tutorial to the letter (password_reset controller renamed to 'reset' and I used my own existing m...

Problem with a frozen webrick

Hi fellows, I have a problem with a rails app, an intranet that i am developing for my company. The problem is really weird, because i'm trying to reproduce it and i couldn't do it. The app works without problems in my notebook, on linux with mysql, but in the dev server that we use (which also uses linux and mysql) it hangs up after th...