ruby-on-rails

Database Design Related

I would like the users be able to create their accounts (which stores the login and password information - Accounts table) and once the email is verified, they have the option of creating their own person record (which stores the other information such as first name, ... - People table). I also want the users (Account holders) be able to...

Setting initial value for primary key in Rails (i.e. first object's id is 1000 instead of 1)

What's the best way of going about this. Is there something I can put in the migrations? Thanks in advance. ...

Can you do an :order in ruby after a find?

Is it possible in ruby/rails to order a result set after doing a find? For example, is it possible to do something like this Warning: Does not work if type == 1 @items = mycompany.items else @items = myhome.items end @items = @items :order => "created_at" I would assume something like this should be possible, but I'm still very...

Search in Ruby On Rails

I have a small site with about 500 photos and 150 visitors per day which is hosted on Dreamhost. I would like to add a simple search engine that does not need to run long time processes which are not allowed on shared host. The search engine should process different fields belonging to various models: Photo, Photo.author.name, Photo.com...

Extending a rails plugin

Hello, I need to extend a plugin by overwriting a method and adding one of my own. So far I have followed Strictly Untyped's guide for this but I haven't had much success. Basically there is a file in the initializer folder that loads the extension from the lib directory. In my initializers folder I have a file with this: require 'amaz...

Is it feasible to use Ruby 1.9 for Rails yet?

I've read that Ruby 1.9 is a lot faster than 1.8, however it seems like it hasn't become the standard in the Rails community yet. What are the pros and cons of using Ruby 1.9 for new apps? Edit to say: What I found confusing was that while its not officially recommended, it seems like 2.3 brought compatibility. Just wondering if people ...

Passenger not passing params hash to Rails application on Mac OS X

I have an existing rails application that works well on Passenger for Linux. It works well on a local mongrel instance. The DB is postgresql in all cases. However, when I installed Phusion Passenger 2.2.4 on a spare Mac with OS X Leopard (running 10.5.7), the params hash does not get passed to the underlying rails application. Are there ...

Authlogic: Assuring that a user can't log in twice.

Is there an easy way in Authlogic (haven't found nothing browsing the docs) to assure that a UserSession can't be created if the User already has an UserSession object? In other words: I want to make sure that a user can't log in twice with the same credentials. UPDATE: Check the comments on thief's answer to find the solution to this...

Rails Nested resource access problem in resource_controller

I using the Rails resource_controller plugin. I have a ReleasesController, which is nested within a UsersController and a ProjectsController. Resource_controller fails when it attempts to pull the release from User, but succeeds from Project. The problem under User is finding the Release results in an object of type, Enumerable::Enumera...

Why would the browser cache assets (images, js, etc.) while GETting but re-request everything after a POST + 302 redirect?

We've got our ETags and expiry headers setup properly and when browsing around the site without posting it is really very snappy. However, after any POST (which is almost invariably followed with a 302) you can see the browser re-request all the images. Is there something that could be causing this? Is there a setting that handles thi...

Testing the Ruby on Rails weblog(netbeans edition)

I recently started learning ruby on rails. I completed the weblog walkthru(links below) and want to make tests for it. I took this functional testing from the video version of the weblog demo. Now i want to make this testing work for the netbeans edition, which actually is structured differently in terms of how the comments relates to th...

Authlogic and Namespace in Rails

Does anyone have an example of setting up Authlogic with a namespace in Rails? I have an "admin" namespace, which contains many "admin" related controllers (products, categories, etc.). map.namespace :admin do |admin| admin.resources :products, :active_scaffold => true admin.resources :specials, :active_scaffold => true admi...

How do I do reflexive self-join relationships in ActiveRecord?

I'm trying to implement a social networking style friendship model and I didnt have much much luck trying to figure out the plugins available out there. I think I'll learn Rails better if I do it myself. So here's what I have : class User < ActiveRecord::Base has_many :invitee_friendships , :foreign_key => :friend_id, ...

Determine if a string is a valid float value

Is there a way to simply check if a string value is a valid float value. Calling to_f on a string will convert it to 0.0 if it is not a numeric value. And using Float() raises an exception when it is passed an invalid float string which is closer to what I want, but I don't want to handle catching exceptions. What I really want is a meth...

Is alias_method_chain synonymous with alias_method?

If these two methods are simply synonyms, why do people go to the trouble of writing the additional characters "_chain"? ...

Best way to learn how to combine Blueprintcss and Compass/Sass?

I would like to apply Blueprintcss and Compass/Sass to a Rails project. Should I learn Blueprint first or Compass/Sass first or are there any guides on how to use the two of these together? Also, does it make any difference that it's a Rails project? Could this combination of technologies be just as easily applied to, say, a Java proje...

Capistrano on Windows: 'cap deploy' defaults to wrong username

Hello all, I am trying to use Capistrano to connect over ssh with svn in order to deploy an app to prod from a windows dev box (Aptana Studio Community Edition). When I run 'cap deploy' it starts executing tasks in deploy.rb, then it asks for a password for user account 'a' but I need to connect using account 'b' not 'a'. User account '...

Common usage of Rails applications ?

What are the most common tasks for Rails applications? I mean, for example, for small and simple sites people usually choose PHP, because it's really easy to maintain and to deploy, most hosting platforms support all your needs. But I'm interested what people usually produce with Rails. What kind of applications? ...

Best way to combine fragment and object caching for memcached and Rails

Lets say you have a fragment of the page which displays the most recent posts, and you expire it in 30 minutes. I'm using Rails here. <% cache("recent_posts", :expires_in => 30.minutes) do %> ... <% end %> Obviously you don't need to do the database lookup to get the most recent posts if the fragment exists, so you should be able to...

does Rails 2.3 support a file-based session store?

Does Rails 2.3 support a file-based session store out of the box any more? It looks as though it supports only use of active_record_store and mem_cache_store, in addition to the default cookie-based. If it does support a file-based session store, how is that configured? It seems as if it should be easy to find a definitive yes or no ans...