ruby-on-rails

Capistrano not restarting

Capistrano is deploying cold, deploying updates and uploading the symlink fine. It will not however restart. I notice that permission is denied on the /script/process/reaper file. I have found a suggestion implying the file needs updated permissions. Does anyone have experience with this? Macintosh-5:barcoden fogonthedowns$ cap deploy...

ruby on rails many to many relation between same model objects

Is there a way of creating many to many relations between same model objects? The idea is that I have a user model and would like to allow users to link to each other. The end result would be a traceable network of relations and a way to find out the relation between 2 users. ...

Advice for Setting Up Rails Sites for Prototyping

I'm learning Ruby on Rails and have just signed up with LunarPages as my webhosting company. To start, I want to write some test applications and get them uploaded and running on my website just to understand how things work. However, I don't want anyone looking at what I'm working on as I learn. Does anyone have any advice as to how ...

Rails data modeling question

I am creating a simple todo app where I have 2 types of tasks. 1) regular tasks - These have a due date 2) recurring tasks -These are poped up as reminders on specified date. They can be created either as weekly or monthly reminders. If created for a week, it will be poped up on each week (on a specified date on the week). Likewise for...

testing and establish_connection

Hi, could you tell me plz - how to write tests for projects, which uses in model establish_connection to connect another database? ...

Default Logical Sort on Resultset Array RubyonRails

I've add a custom sort to an ActiveRecord model by defining a method like this: class MyClass < ActiveRecord::Base belongs_to :parent_model #this would be the many in a has_many relationship def <=>(other) self.att <=> other.att end end Suffice it to say, the logic actually being employed in the comparison is a bit more com...

undefined method `confirm_password' - does this imply AuthLogic isn't triggering for my request?

Hi, Pretty much have the Authlogic example type rails app setup. I'm getting the following error when I click on the registered link. From a generic point of view I can't quite see how the view "form.label :confirm_password" is support to run without raising an issue, noting that this field does not exist in the User table in the data...

Odd rounding problem using the ruby printf-format-specifier

Has anybody got any ideas on this one? When we run: printf("%.0f", 40.5) On a windows box the return is "41" but on our production ubuntu server we're getting "40" ...

What is curl and what are its uses for rails developers?

Ive seen mentions of curl here and there on rails blogs and ive scanned some posts here on stackoverflow but im still a bit in the dark as to its use especially when it comes to rails development. Is it useful for testing? Im currently learning the ins and outs of testing and one of the things i need to do is test a before filter that ...

How do you pass a POST method in a url manually?

I need to give an external payment site a return url to my site after a customer pays. It will be to my create action in a RESTful subscription controller. Ive tried giving the payment site this blah.com/users/7/subscription/?_method=POST but on return my app keeps trying to call my show action presumably because it thinks its a get ...

Rails routing is being wonky with IE

Wanting to play with jQuery, Orbited, and FasterCSV, I made a Rails chat application. You can browse to a URL and there is a chat window that is similar to IRC. You can also export the contents of the chat window by visiting the same URL but adding a ".csv" extension to the URL. HTML version: http://host.name/channel/sweetchatroom CS...

What is the best way to query a datetime field against date fields?

Hi, I just want to know what you guys are doing when you have a datetime field, ie: Game.first.starts_at => Thu, 03 Dec 2009 20:20:00 EST -05:00 And you want to query it against a date field: 3.days.from_now.to_date.to_s(:db) => "2009-12-03" Currently I make this work by using the B...

Namespaced resources

This is an excerpt from my config/routes.rb file: resources :accounts do |account| account.resource :profile, :except => [:new, :create, :destroy] account.resources :posts, :collection => { :fragment => :get }, :has_many => [:comments, :likes] # even more code end I...

Typecasting base class models in Single Table Inheritence(STI) scenario

class User < ActiveRecord::Base end class Consumer < User end class Merchant < User end u = User.find(id) How do I type cast the variable u to the type Consumer? ...

Cannot load Rails application with gruff gem

I am trying to load a Ruby on Rails application that uses the Gruff gem. I can load Gruff fine in irb, but whenever I try to load the app (via ruby script/server), it crashes. Here's the full stack trace: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/source_index.rb:303:in `search': undefined method `empty?' for :gruff:Symbol (NoMethodEr...

Identify the referrer domain in rails

Hi All, I have a web site which has 2 domains ex : www.site1.com www.site2.com (which will forward to www.site1.com with domain masking) www.site1.com is where the actual web server rungs www.site2.com is just a domain name forwarder and I use mask to make the user feel he/she is in www.site2.com even though he/she is in www.sit...

which authentication method is best for a client app having to interact with a web application that has authentication?

Hi, Just wondering what people would suggest for an approach for a WinForms client that will have to interact with my web application (ruby on rails, which will use AuthLogic for authentication). For example options such as: * authentication each HTTP request, * gets a token for the session until it times out * other? This can be t...

Rails validate_existence_of plugin

I'm reading the book Learning Rails by O'Reilly and it recommends using the validate_existence_of plugin. When I run: ruby script/plugin install http: //svn.hasmanythrough.com/public/plugins/validates_existence/ it says it's already installed, but when I use it, I get a message saying: NoMethodError in AwardsController#index undefine...

why am I getting 'could not find gem rails locally...' when trying to upgrade InstantRails2.0 to rails 2.3?

The full error message is "could not find rails gem locally or in a repository". I've read the Rails Wiki about upgrading rails and it doesn't have any info on this error. I'm running on WinXp. The Rails Wiki said I needed to first do update_rubygems, and it appears I was able to do that successfully. My ruby version is 1.8.6. I googled ...

help with rails associations

I want to implement a messaging system for my app. I have users. What exactly should I do? create a messages model with foreign two user foreign keys??.. what would be the most approproate way of getting this done? My worry is that if I query "message.user" I wont know if Id be getting the sender of the receiver of the message ...