ruby-on-rails

How do I rollback capistrano tasks upon failure?

In my Capistrano deploy.rb, I have a couple of daemons like delayed_jobs and fetcher, starting and stopping depending on where they are in the deployment process. This method would create problems if a deployment fails, because the daemons wouldn't be managed properly (ie. two processes spawned instead of one, or processes were shutdown...

gem install mysql error on solaris

[root@zhaoonline-data sbin]# gem install mysql Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /opt/ruby/bin/ruby extconf.rb checking for mysql_ssl_set()... no checking for rb_str_set_len()... no checking for rb_thread_start_timer()... no chec...

Require a specific version of ActiveRecord

I have both Rails 2.3.4 and Rails 3.0.0.beta installed on my local machine. I am using ActiveRecord in a stand alone ruby script and when I do require 'active_record' 3.0.0.beta is loaded. How can I force it to require 2.3.4 instead? (without uninstalling 3.0.0.beta) ...

Awesome nested set plugin - how to add new children to the tree at various levels

Hi I have a tree structure.. I am using Awesome nested set plugin. how to add nodes to the children at various levels. Please help me. I want to add ,edit and delete nodes at any levels. Can anyone help me for the same? ...

Rails - Using checkboxes to select multiple objects and having a choice of actions to perform.

Id like to be able to create checkboxes for a list of objects. Then offer the user a number of actions to perform on the objects selected. I.e. delete, archive etc. I know of ryan's screencasts but it doesnt explain how to create links to multiple actions for the selected objects. It just showed him create a form_tag with a url to one a...

cheap way to scale a rails application

I have an application, that is becoming big, but until now, its not giving me a good revenue. That means, short money to re-invest on that. In this scenario, i found a way to make a "cheap distributed rails" deployment. I've got 4 VPS. All of them are in the same physical server. I added a load balance server running HAproxy in one ded...

Keeping dates in order when using date_select and discarding year in Rails?

My app has users who have seasonal products. When a user selects a product, we allow him to also select the product's season. We accomplish this by letting him select a start date and an end date for each product. We're using date_select to generate two sets of drop-downs: one for the start date and one for the end date. Including ye...

Retactoring advanced has_many example

Hello, My user model has three relations for the same message model, and is using raw SQL :/ Is there a better more rails way to achieve the same result? Could the foreign key be changed dynamically? e.g User.messages.sent (foreign key = author_id) and User.messages.received (foreign key = recipient ) I have been trying to move some o...

Problem with sessions, subdomains and authlogic in Rails.

I've got a rails app with authlogic authentication and a username.domain.com structure built with subdomain-fu. But my session breaks when going from domain.com to username.domain.com. I've tried to add config.action_controller.session = {:domain => '.localhost:3000'} to my development.rb but that seams to break authlogic disabling s...

How to add :format options to a named route in Rails?

I've got a named route called profile and I would like to be able to access it as json. But when I look at my rake routes output I see that the (.:format) is missing. How do I add it to a named route? user GET /users/:id(.:format) {:action=>"show", :controller=>"users"} profile /:username {:action=>"show", :contro...

How can I get "request" object in ActionController::SessionManagement::ClassMethods

Now, I'm a user of ruby-on-rails 2.3.5. I want to override the method of "session_store" in ActionController::SessionManagement::ClassMethods. In my overrides, I need the "request" object which has a lot of useful information such as host name, domain name, etc... Do you have any idea to get the "request" object in that method. My rails ...

Custom formats in Ruby on Rails

I'm creating a website in Ruby on Rails, where users can login using RESTful Authentication. Someone can get a specific user using html, xml and json, just like scaffolding. But I want to add one more format: vCard (e.g. /users/1.vcard). This has a specific format, but how do I define my own formats? Using views, or must I use another wa...

rails: best way to store comments in mysql

Hello. Okay i have two models: posts and comments. as you can think comments has column :post_id. My models Comments belongs_to :post Post has_many :comments So, this is pretty simple association but i have some problems with ordering comments. at first time, when i create my comments migration file i just add column :position...

Odd Drag and drop sorting error Rails for nested attributes

I've got this weird bug when trying to use drag and drag for two models (one nested within another). I've a category model which has many apps. In my category index page, I tried use "content_tag_for" to sort categories and apps within each category. But for some odd reason only the first element has drag, drop enabled. I can drag and d...

[Rails] checkbox to update attribute

[Updated a bit] I have a Task model that has a :completed boolean attribute. If I click on it I want it to execute the 'finish' method. The main problem is that I am displays a series of checkboxes in a list and subsequent checkboxes after the first one are ignored. The method is never called for the given task/checkbox combo. I have th...

Ruby and Ruby on Rails offline API documentation

Hi, In the past I used railsbrain.com to have a nice and handy offline api documentation. But they stop at version 2.3.2 Is there any other solution with latest version. Thanks ...

Extend RedCloth gem

Hi, I want to put a new textile tag like h1. , but its name will be map. So I found the following article but it doesn`t work on RedCloth 4.2.2 Thanks ...

ActiveRecord Associations Question

I'm new to rails and have volunteered to help out the local High School Track team with a simple database that tracks the runners performances. For the moment, I have three models: Runners, Race_Data and Races. I have the following associations. Runners have_many Race_Data Races have_many Race_Data I also want create the association ...

Rails 3 and RJS

Hi, I use the rails 3.0.0.beta Is there any new syntax to write RJS, here is an example def remote_create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save # add @photo's thumbnail to last import tag format.js { render :update do |page| page.insert_html :bot...

I get an Exception when trying to implement reset password with Authlogic

Hi, I'm using Ruby on Rails 2.3.5 and Ruby 1.9 and implmeneted Authlogic as my authentication engine. Authlogic works fine. But now I have been trying to implement password reset using the following tutorial: http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic/ But I'm getting the following exception when I ty...