ruby-on-rails

session difference between active_record_store and cookie_store

Hi, In rails 2.3, I changed session store from cookies to active_record. I compared session.inspect between the two stores. In cookie_store, it showed a lot of info but in active_record_store it showed nothing(just {}). My main concert is session_id. You can't get session[:session_id] in active_record_store. Is this right behavior? Do ...

MS developer wanting to jump into RoR, what was your experience like?

Are there any 100% Microsoft developers out there who have ventured out into learning Ruby on Rails? If yes, what was the learning curve like for you? How about the time frame to be competent? What were the hardest aspects of making the change? ...

Login and use rails from C++

I need to use a rails app from C++. I say login in the title because that's one of my options. As far as I see it, I either need to do the standard login, and keep track of a session or something in the C++ code, or use an API token of sorts, and just pass that on every URL and never actually create a session on the rails side (which us...

Using build with has_many :through

I have an Entry model and a Category model, where an Entry can have many Categories (through EntryCategories): class Entry < ActiveRecord::Base belongs_to :journal has_many :entry_categories has_many :categories, :through => :entry_categories end class Category < ActiveRecord::Base has_many :entry_categories, :dependent => :de...

Rails cucumber problem

Seems like cuke doesn't show the full error message (at least when problem occurs in template) which makes it really hard to locate the problem. Here is what it outputs on some error: ... And I am on checkout page # features/step_definitions/webrat_steps.rb:6 You have a nil object when you ...

Rails, Restfully Parameterize New Action

Hi Everyone, I would like restfully add a parameter to the new named path. So for example, if I had a reservation resource, i would like to use the helper route: new_reservation_path(date) which would create the url: /reservations/new/2009-6-10. I then would grab the date in my new controller using params[:date] and defa...

Why can't Ruby on Rails find this class?

Okay. So I have three models, a, b and c. a has_one c, b has_many cs, and c belongs_to both a and b. When I reference "cs" in a method of b, it comes out fine. But when I reference "c" in a method of a, it can't find the reference; it says "c" is an 'undefined local variable or method'. I know that c objects are getting created, because ...

Is there a way to output something in a gem?

It seems that print, put, or logger.info doesn't work in an included gem. I was wondering if there was a workaround. Thanks! ...

Multiple counter cache columns with aasm

I am looking for a way to cache the number of each state. I have done counter caching before, but is there a way to create multiple counter_cache columns for each state and keep them updated or should I look elsewhere for caching these values. aasm_column :state aasm_initial_state :unopened aasm_state :unopened aasm_state :contacted a...

Contest ranking question - how to rank entries in multiple categories?

I'm currently developing a video contest web application using Ruby on Rails. It integrates closely with YouTube, which it uses for submitting videos, comments, average rating, and popularity stats. The application will also count Twitter and (possibly) Facebook mentions, and count the number of times visitors have clicked an "Add This" ...

Problem in using thickbox3.1 with rails..!!

I am using rails to build my application and I want a thickbox on clicking a particular link.. I use the below code in my partial which is displayed in a division of a page and on clicking the user.name, i need the thickbox.. when i use the below code, nothing happens.. <%= link_to_function user.name,remote_function(:update=>"result", :u...

Rails unit testing gone completely wrong

I don't know what and when happend on my code but I got hundereds similar erros (not failures) of this : NameError: uninitialized constant ActiveSupport::Callbacks::Callback::NORMAL And my tests function just go useless now, as even I put something like: should "failed" do assert false end It still returns passed, any idea ? ...

What can I learn from Grails?

If I know Rails, what new ideas/patterns would I learn if I looked at Grails? I have no intention to move to Grails and no need for a Java stack, but if there are neat ideas I could learn from Grails I'd like to learn them. ...

RSpec controller testing - blank response.body

I am stuck with a problem when testing my controllers with RSpec - the response.body call always returns an empty string. In browser everything renders correctly, and cucumber feature tests seem to get it right, but RSpec fails each and every time. Other expectations on the response object, such as response.should render_template('index...

How do I install Ruby's SQLite3 extension on Windows?

This is the first time I am running Ruby on Rails. When running the "blog" application I got the message "We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly." Then I checked the CODE\blog\log\development.log and got this: /!\ FAILSAFE /!\ Tue Jun 30 15:22:55 +0100 2009 Sta...

java font format exception on osx with java 4 update

I'm getting a java.awt.FontFormatException: Unrecognised Font Format error, and I believe this has been happening only since performing the 10.5 java 4 update, though I can't verify that to be exact. My java version after the update is 1.5.0_19 I'm using jruby in rails to generate a font with the following code: font = java.a...

math functions in active record sql queries? (pow, sqrt etc)

Active Record is not recognizing common SQL functions like POW and SQRT in the "find" method or "find_by_sql." How do I work around this? There seems to be no literature out there :-( ...

Item's page and will_paginate

I have some photos that are split on successive pages through will_paginate plugin. When you open a photo and then return to all photos using a link, you always return to the first page (e.g. the photo is displayed on page 5, you open the photo, click a link to show all photos and expect that you are on page 5 again, but you are on page ...

Ruby on Rails Collection select - how to pre-select the right value?

Hello, I spent the last three days working on the collection _ select form helper for my "listing" - form, where users can select a category. I would like to have the category currently set in listing.category_id as the preselected value. My view code looks like this: <%= l.collection_select(:category_id, @category, :id, :name, optio...

In Rails, display time between two dates in English

In a Rails project I want to find the difference between two dates and then display it in natural language. Something like >> (date1 - date2).to_natural_language "3 years, 2 months, 1 week, 6 days" Basically this for ruby. Google and the Rails API haven't turned up anything. I've found some things that will give you the differen...