ruby-on-rails

Checking in code without deploying on Heroku

I've been successfully running an app on Heroku, but now would like to work with a collaborator on it. Is there a way with can check in (and pull) code without deploying it live? Right now a git push deploys to code the live site. ...

how can I destroy a record without an ID column in ruby ActiveRecord?

hi, I have a table without an ID column. When I try to delete from it using ActiveRecord the generated SQL is DELETE FROM table_name WHERE ID=NULL, which obviously doesn't work. Is there any way to delete from the table using ActiveRecord, or at least run a raw SQL delete query with placeholders (so it's not vulnerable to SQL injection)...

running "complex" queries with amazon SDB (simpledb) - aws-sdb + ActiveResource

I am considering the following a "complex" query, given the fact that simpledb is a really simple data storage: I am trying to query a aws-sdb domain with an OR query. using ruby, rails (2) and ActiveResource. I am using the code examples from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1242 (which don't show Or ...

Ruby, ODBC: MD5 checksum on ruby-odbc

I'm following the instructions here, and so far so good, but I'm having trouble figuring out this part: Lastly, download your target version from the ruby odbc project page and do a MD5 checksum on it. What exactly am I supposed to be running MD5 on? The tar file? extconf.rb? I've been poking around for awhile but I just don't ...

Rails 2.3.x: possible to combine these validations into one?

Is it possible to keep things DRY and put this into one validation line? validates_presence_of :login validates_uniqueness_of :login ...

Rails Model and calling another Controller from a View RESTfully

I have an application where I create an array of objects (Matches) that do not inherit from ActiveRecord. They are presented in a view and the user selects which they want to play. At that point, I want to create a new MatchHistory object, which does inherit from ActiveRecord. The array itself is also an object (Round). I wonder if my o...

Rails drop down box posting null

I have the following drop down box in a form for rails: <%= f.select (:boolean, options_for_select([["Yes", 1], ["No", 0]])) %> Other drop down boxes in the same form post correctly, but this one posts null. Others in the same form: <%= f.select (:kids_in_college, %w{1 2 3 4 5 6 7 8}) %> #posts correctly <%= f.select (:year, %w{2009-...

Securely persist session between https://secure.yourname.com and http://www.yourname.com on rails app

My rails site posts to a secure host (e.g. 'https://secure.yourname.com') when the user logs into the site. Session data is stored in the database, with the cookie containing only the session ID. The problem is that when the user returns to a non-https page, such as the home page (e.g. 'http://www.yourname.com') the user appears to hav...

Executing cucumber in Rails results in error

I am trying to learn ruby on rails, and am trying to set up cucumber. I get this error when trying to run it. I think the picture may say more than I could. ...

How do we know if a query is cache or retrieved from database?

For example: class Product has_many :sales_orders def total_items_deliverable self.sales_orders.each { |so| #sum the total } #give back the value end end class SalesOrder def self.deliverable # return array of sales_orders that are deliverable to customer end end SalesOrder.deliverable #give all sales_orders t...

Rails: How do I display flash[:notice] modally

I'm looking for a way to recreate the effect used by stackoverflow to display information about badges awarded etc to users, except I want to use the effect to display my flash messages. In case it's not clear, I'm talking about the way site updates appear at the top of the browser window and stack there until the user clicks the X bu...

fieldWithErrors not wrapping every error field

Notice the following result when I submit blank :title and :description fields The validations are in the controller: class Question < ActiveRecord::Base validates_presence_of :title validates_presence_of :description And, the form is generated with those names: -form_for(@question) do |f| = f.error_messages = f.label :tit...

Is the version number in rails schema.rb used for anything

Now that Rails has timestamped migrations, the single version number at the top of /db/schema.rb seems pointless. Sometimes the version number ends up incorrect when dealing with multiple developers, multiple branches, ... Does rails even utilize that :version parameter anymore? And is there any harm in it being incorrect (as in doesn...

Rails Variable across all controller actions

Hello, This should be a very simple rails question. I have a variable like the following. @administration = Administration.first I want this variable to be accessible through every controller action across all my controllers so for example if I have a Product controller and inside of it I have the usual CRUD actions, I want the @adm...

Why does schema.rb change (in the eyes of Git) when just running rake db:migrate?!

This is a little general I know, but it's been bugging the hell out of me. I've been working on lots of rails projects remotely with Git and every time I do a git pull and see that there is some sort of data change (migration, or schema.rb change) I do a rake db:migrate. These generally run fine and I can continue working. But if you d...

Help doing a dynamic sort?

I have a notifications table which contains different types of notifications for different events. Inside the table is a notifications_type:string column that contains the type of notification, i.e. "foo" or "bar" or "oof" I want the user to be able to select what notifications they want to display, so there are checkboxes below the res...

Passing value from :locals to link_remote_to

In my edit.haml file, I have =render :partial => 'old_question_tags', :locals => {:current_question => @question.id}. I'd like to pass the value in :current_question to a link_to_remote call in _old_question_tags.haml: #{link_to_remote image_tag('red-x.png', {:alt => "Remove #{t.name} tag"}), :url => {:action => 'remove_old_tag_from_q...

What's a good way to set up a development environment on OS X for ruby, rails, and git?

I'm going to start development on a web app using ruby, rails, probably either postgres or mysql, and most likely apache. I'll be using a git repository with the master repo on another server. I've searched through stackoverflow and done some Googling... so here's what I have so far... What are your opinions on what's described on this...

How to upgrade ruby and rails in mac os snow leopard

I want to upgrade my Mac Snow Leopard ruby from 1.8.7 to 1.9.1 version, anyone know the painless and best way to upgrade? because i read some forum/post/blog/discussion say that is it not good to override the ruby that ship by apple and what the best way to upgrade rails from version 2.2.2 to 2.3.8? because all the information that i fi...

Generating Google Maps markers using Ruby

I would like to do a very simple task: add some markers in a Google Map using a list of addresses from an array. I have been thinking about generating the Google Maps JavaScript API code using ruby (printf) but this does not seem like a very clean and beautiful solution... I have read about YM4R for Ruby on Rails... my project is prett...