ruby-on-rails

ARCHFLAGS not taking command (MySQL 64-bit ruby gem installation issues on Snow Leopard)

Hello all, I've never used the ARCHFLAGS command before and am in way over my head. I'm struggling with getting the MySQL gem working on Snow Leopard in 64 bit. What I'm doing is this command: sudo env ARCHFLAGS='-arch x86_64' gem install --verbose --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config The...

question about rails associations

consider this code class User < ActiveRecord::Base has_many :views has_many :posts, :through => :views, :uniq => true has_many :favorites has_many :posts, :through => :favorites, :uniq => true has_many :votes has_many :posts, :through => :votes, :uniq => true end # controller code user = User.find(3) posts = user.posts #...

updating a select box based on another (Ruby on Rails)

I'm in need of a more complete example on how to update a select box based on the results of a second select box in Ruby on Rails. I asked about this already here. I've read through the feedback from that posting, but am not having any luck figuring this out, and I've been trying for hours. Anybody know of a better (and more complete) ex...

Unique keys for Sphinx along three vectors instead of two

I'm trying to implement thinking-sphinx across multiple 'sites' hosted under a single rails application. I'm working with the developer of thinking-sphinx to sort through the finer details and am making good progress, but I need help with a maths problem: Usually the formula for making a unique ID in a thinking-sphinx search index is to...

Understanding Rails Variable Types in Debug

I was trying to debug why <%= @user.address1 %> wasn't showing up in the view. The associated column was setup as a string, as in: t.string "address1" t.string "address2" t.string "city" t.string "state" t.string "zip" t.string "phone" When I debugged the model using debug(@user), I got: address1: 123 Main St. city: Sant...

Invalid source reflection macro :has_many :through

I have such angry associations: financings >- events >- subprograms >- programs. I want to get acces to last_financings from programs through all of them so code is: class Fcp < Program has_many :fcp_subprograms, :foreign_key => 'parent_id' has_many :subprogram_last_actual_financings, :through => :fcp_subprogra...

Debugging/Breakpoint-ing the Rails Core with Ruby-Debug?

How do I debug the rails gems? I've just found the beauty of ruby-debug and am real excited, but I want to step through the routing code in action_controller, but the debugger isn't set up at this time, it seems like it's just skipping over my "debugger" calls in action_controller/routing/route_set.rb for example. What am I missing? ...

activerecord_session_store vs. sql_session_store

Does anyone have more recent stats on the speed gains in SqlSessionStore over ActiveRecord Session Store? Is anyone out there using SqlSessionStore because of gains over ARStore? More of a curiosity I guess. Seems there isn't a lot new on the SqlSessionStore side since like '07, even though the github.com repos show updates as late as ...

handling BC dates in Ruby on Rails

Hello, I'm planning to make an application that needs to store dates way before 1970. Maybe even BC dates. Do you think I should store and handle that manually or can I use the Date/Time classes in Rails or use some plugin? Thanks, Tam ...

ActionMailer emails "sent" in development.log, but not received

I'm having problems actually sending via ActionMailer in development, on my localhost, with Rails 2.3.2 and Ruby 1.8.6. The development.log shows that it has "sent" the email with no errors, but the email is not received. I have tried multiple email addresses for sending and receiving and have tried multiple configs and plugins, but cann...

Glassfish can't find activerecord-jdbc-adapter

I'm trying to deploy simple Rails app on glassfish v3 and get the following error: org.jruby.rack.RackInitializationException: Could not find RubyGem activerecord-jdbc-adapter (>= 0) Environment details: App is packaged as war using warbler. JRuby 1.4.0 installed locally, with activerecord-jdbc-adapter gem installed. App is configured...

rails ajax render :update in controller responds slowly

Hi, I'm working on a rails project and I experienced that the response to ajax calls are slow in both development and production. Response comes around 8 sec. I observed also that i have some actions that has a response time around 80ms. The difference in the two acitions is that the slower was rendered using render :update do |page| .....

ruby on rails getting back end id value from selected autocomplete field

hi all, regarding ruby on rails. In the autocomplete field, when the user selects tagname, i need to get the back end tag_id. the way we do in selection box, where it is possible to get the value as an id in the autocomplete field plugin. and when the user can select incremental selection separated by , . i need to get the selected i...

how to specify multiple relationships between models in rails using ActiveRecord associations

Say there're two models : User and Post, i want to keep track of who has read which post, and who writes which post, which user favorites which posts etc. Then i come up with the following solution: class User < ActiveRecord::Base has_many :writings has_many :posts, :through => :writings has_many :readings has_many :posts, :thr...

marshal data too short!!!

My application requires to keep large data objects in session. There are like 3-4 data objects each created by parsing a csv containing 150 X 20 cells having strings of 3-4 characters. My application shows this error- "marshal data too short". I tried this- Deleting the old session table. Deleting the old migration for session table. ...

Why records are not getting deleted after test/spec

Am using 'devise' gem for authentication and rspec for testing. My problem is after spec execution the test data is not getting cleared from DB, because of this subsequent execution of specs fail. Following is the spec: describe User do it "should return a valid user when valid email and password are used" do user = User.new(:email...

Replacing Broken External Images With Custom Image

I'm looping through an array of URL strings of images hosted at an external site. It looks something like this: def get_image_urls image_url_array.each do |image_url| puts image_tag image_url end end Which will return the URLs of images hosted on the external site. The problem is, some of these images might be broken (404). S...

acts_as_ferret with multiple hosts

I've got everything working with ferret and acts_as_ferret for development (or localhost DRb), but I can't get my multiple host deployment working. All of the remote systems get ECONNREFUSED when accessing the port. On the ferret server, the daemon is listening on localhost only despite the configuration listing the FQDN as the host. ...

Move this logic into the find method?

This is working as is, but I'm pretty sure this is sloppy. Any tips on how to get all of this logic more rails-ish? I'm trying to implement will_paginate with this, but first I need a cleaner way of selecting the right records. #shoe table ------------------------------------- size | brand | color | sold -----------------------...

dynamic select population based on result from another select_tag

Hello, I have a question with regards to this tricky situation. I have code for a single select box where I can select a year, and based on the year, I want to return all possible values pertaining to that year in another select tag.... <%= select "month_end", "year", MonthEnd.find(:all, :select => 'DISTINCT year', :order => 'year').c...