ruby-on-rails

How to mix mongodb and a traditional db in Rails?

I am considering using MongoDB (mongo-mapper) for a portion of my rails application. I am not ready to go whole hog MongoDB because there are too many useful gems that depend on a traditional DB. That being said there are parts of my application that would be great to leverage a document database. Has anyone had success mixing the two...

How do I set default search conditions with Searchlogic?

I've got a search form on this page: http://staging-checkpointtracker.aptanacloud.com/events If you select a State from the dropdown you get zero results because you didn't select one or more Event Division (checkboxes). What I want is to default the checkboxes to "checked" when the page first loads...to display Events in all Division...

open_id_authentication - "OpenIdAuthentication.store is nil. Using in-memory store." problem

Hi, I am trying to make the open_id_authentication plugin working. Initially was doing it with authlogic but abandoned because it feels like much more hassle the help. The problem is that I am getting OpenIdAuthentication.store is nil. Using in-memory store. warning in the log which prevents from authenticating users correctly. Here i...

Updating a user creates a new hash of an empty password :(

I'm creating a user system for Rails, and login, sign up etc... all works. Awesome! At least, that is what I thought. I tried to update the profile attribute of a user, but I don't send a new password or username with it. I use this in my User model: protected def after_validation self.password = Password::update(self.password) end ...

Error starting mongrel on windows after using RubyInstaller 1.9.1 RC2

I installed Ruby via the RubyInstaller 1.9.1 RC2 available from rubyforge, updated gems, and installed rails. Everything worked fine using webrick. For fun, I installed mongrel using "gem install mongrel". The installation went fine: Successfully installed gem_plugin-0.2.3 Successfully installed cgi_multipart_eof_fix-2.5.0 Successful...

Rails HABTM Scoping to current subdomain

I have the following associations: class User < ActiveRecord::Base has_and_belongs_to_many :brands, :join_table => 'brands_users' has_and_belongs_to_many :companies, :join_table => 'companies_users' end class Brand < ActiveRecord::Base belongs_to :company has_and_belongs_to_many :users, :join_table => 'brands_u...

How to generate a random date and time between two dates?

The title pretty much says it all. Don't overlook the 'date AND TIME' part though. ...

How to find out currently logged in users in Rails 2.3.5?

Hi All, Does any one know solution to tracking online users in Rails; when you have cookie based sessions? I am using Rails 2.3.5. If yes please let me know. Thanks, Atul ...

ruby on rails named scopes (searching)

I have a named scope (name) combination of first and last name and I'm wanting to use this in a search box. I have the code below: named_scope :full_name, lambda { |fn| {:joins => :actor, :conditions => ['first_name LIKE ? OR second_name LIKE ?', "%#{fn}%", "%#{fn}%"]} } def self.search(search) if search self.find(:all, :conditi...

Is it possible to have variable find conditions for both the key and value?

I'm trying to pass in both the field and the value in a find call: @employee = Employee.find(:all, :conditions => [ '? = ?', params[:key], params[:value].to_i) The output is SELECT * FROM `employees` WHERE ('is_manager' = 1) Which returns no results, however when I try this directly in mysqsl using the same call with...

How do I send signed emails from ActionMailer?

I'm using GMail as my SMTP server. I have that configuration working just fine: # config/initializers/action_mailer.rb: ActionMailer::Base.smtp_settings = { :tls => true, :address => "smtp.gmail.com", :port => "587", :domain => "www.example.org", :authentication => :login, :user_name ...

[Ruby On Rails] belongs_to with :class_name option fails.

I have no idea what went wrong but I can't get belongs_to work with :class_name option. Could somebody enlighten me. Thanks a lot! Here is a snip from my code. class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.text :name end end def self.down drop_table...

Localhost packet analyzer for Mac

Packet sniffers generally do not capture localhost traffic. I need to inspect some post data in a localhost environment (being generated from a Ruby on Rails development). Do you know of any programs that expose localhost packets? ...

Is it possible to specify a SQL Server schema name in a Rails ActiveRecord migration?

The current convention where I work is to use SQL Server schemas like namespaces (e.g. Company.Employees, Company.Branches, etc.) Is it possible to get an ActiveRecord migration to use anything other than the default "dbo" schema in SQL Server? ...

Convert input to integer before save in rails

Hello, i have a set of select inputs representing a users birthday: birthyear, birthmonth and birthday. And i want to validate birthyear like this: validates_inclusion_of :birthyear, :in => Date.today.year-50..Date.today.year-12 So the user can be at least 12 years but at most 50 years when they are registering. But my problem is th...

dev and prod systems in rails

What exactly is the difference in rails between dev and prod environments. When I develop an application in dev mode, do I have peformance problems, or others if I clone my dev environment on prod? ...

Stable URL of acts_as_taggable plugin in Ruby on Rails

Hi, In one of my applications on Ruby on Rails, I am using acts_as_taggable plugin. Coding was doing fine and suddenly it started giving following error. RuntimeError (acts_as_taggable_on_steroids has been moved to github: http://github.com/jviney/acts_as_taggable_on_steroids): app/models/post.rb:2 app/controllers/post_controller...

Rails and the <span> tag

I'm fairly new to Ruby on Rails, and I'm attempting to create some fancy CSS buttons using the "sliding doors" technique. I have it almost working, but I feel like there has to be a better way to handle the tags for a link. The way I'm currently doing it: <%= link_to '<span>New car</span>', {:action => "new"}, :class=>"button" %> ...

Range with leading zero in ruby

Hi, i have a form where my users can register to my site. They fill in theirs birthdate in the form: birthyear, birthmonth and birthday. So i am using Range to create the select in the form like this: = f.select(:birthmonth, options_for_select((1..12))) But that doesnt start the single digit numbers with a zero like i want: 01, 02, 03...

testing devise with shoulda and machinist

hello! I´d like to test my app with shoulda and machinist. I use the devise authentification gem. I get following error: $ ruby unit/page_test.rb c:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be rem oved on or after August 2010. Use #req...