ruby-on-rails

(Ruby, Rails, Javascript) Drag and Drop without bugging the server...?

Hi All, Is there an equivalent of "link_to_function" (instead of ":action") when using "draggable_element"? Basically I need to drag and drop some items and have it reflected locally without contacting the server. My current setup is that I have two DIVs with various list items. I have one full of items with domids "points[selected][...

How to keep public and private versions of a git repo in sync?

I'm releasing an open-source Rails app on Github (probably MIT license). I also want to maintain a private branch/fork of the project that we will use as part of a pay service. What is the best way to organize the repo(s) in this scenario? And, how can I keep the projects in sync when I have updates that should go to both? ...

rails redirect_to problem

Hi, I am developing a rails app and have a question. In my routes.rb: map.connect 'admin', :controller => "/admin/users", :action => "index" So when I go to "http://mydomain.com/admin", it redirects to "http://mydomain.com/admin/users/index". However, the address remains as "http://mydomain.com/admin". Thus, links in the page are wro...

Functional testing Authlogic?

In a few of my controllers I have a before_filter that checks if a user is logged in? for CRUD actions. application.rb def logged_in? unless current_user redirect_to root_path end end private def current_user_session return @current_user_session if defined?(@current_user_session) @current_user_session = U...

What are some good or bad design decisions in ActiveRecord's implementation?

I'm interested in learning more about how ActiveRecord was designed and why particular decisions were made along the way that led to the implementation that we have now. Could anyone provide some examples of good or bad design decisions that were made in ActiveRecord's implementation? ...

Is aliasing methods frowned upon?

I'm developing an online store, and the customer needs the ability to delete an order and have its products automatically restocked (e.g., for test orders). Here's my first try at implementing this: class Order < ActiveRecord::Base def destroy_and_restock restock_products destroy end protected def restock_products ...

Accepting dummy credit cards on a live site with ActiveMerchant & PayPal

I'm setting up a rails site that will accept credit cards with ActiveMerchant and PayPal Website Payments Pro. I am successfully testing against the PayPal sandbox, but need to be able to test on my live site as well. I'd like to implement a solution whereby registrations on my live site with email addresses from my own domain use the Pa...

Running mongrel_rails cluster::start on Windows

I have managed to get mongrel_cluster running on my Windows server (v 1.0.5) ok, but I am having trouble trying to get it to spawning all of the (4) mongrel instances. It launches the first one ok, but then does no more. That one instance serves just fine, but the others are not launched. I assume that this is becasue of: "** WARNING...

Passenger on Windows

Is there anyway to get PAssenger running on a Windows machine? It doesnt appear so, but it seems like many Stackoverflow'ers have use passenger a lot and I was wondering if its possible. ...

(Ruby, Rails, AJAX) TemplateError for second-level partial during AJAX update.

Hi All, Could someone please explain to me why I'm getting an ActionView::TemplateError when I try to use AJAX to update the interface while using the following code: CODE I have the following structure: Site -> Building -> Control. Each loops through it's collection of items and renders a partial for each. From Site to Building wo...

RAILS: Authlogic gem & Userstamp plugin

I have an application that uses the Authlogic gem and needs the functionality of the Userstamp plugin. AFAIK Userstamp works very well with RestfulAuthentication, though I couldn't find anything mentioning using it together with Authlogic. Has anyone of you tried to combine them? Are there issues I should be aware of? Should I use a...

In Rails how do I update form fields in the model?

Let's pretend I want to set all the fields I specify to be = "frog" In the model I can set each one manually using: self.field1 = 'frog' self.desc_field = 'frog' self.fieldx = 'frog' etc.... But how can I this by putting the field names in an array? When I try fields_array=['field1','desc_field','fieldx'] fields_array.each { |f...

Is Rails now working with Ruby 1.9?

Browsing the web says that Rails is not compatible with Ruby 1.9 but I would like to know if it's always the case? And how long should we wait to see a Rails version working with Ruby 1.9? Is it work in progress? In dev stage? ...

Restful_authentication vs. Authlogic

Hello, what do you recommend? Authlogic or restful_authentication? Is it hard, to build the email-activation-step into authlogic (as far as I know, Authlogic hasn't this feature included). ...

getting rid of ruby gems that won't die

I've got a few ruby gems that won't go away. I think it has to do with when I installed them. Occasionally I have forgotten to use "sudo" before doing a gem install, which results in a write error and from what I can gather puts a copy of the gem in my user directory instead of somewhere it can run. But gem uninstall doesn't work. ...

Ruby on Rails: Problem installing gitorious in Ubuntu 9.0.4

I seem unable to install Gitorious. I am trying not to install Ruby Enterprise Edition, but apart from that I have been following the instructions for Ubunut (there were some errors but I have gotten around those). I have installed a number of missing packages and gems, but now I am stuck when I try to migrate the database. I get the fol...

RoR: to_json on an array of hashes

Hello all, I have an array of hashes in a Rails action which i return to client in json format: {"msg": "Got report data.Check 'report' json object. ", "success": true, "reports": "[{\"total_transfers\": 0, \"total_keywords\": 0, \"keyword\": \"plum\", \"total_duration\":1464.0, \"total_calls\": 22, \"total_sms\": 0, \"avg_duration\": ...

Accessing the "session key" cookie name from anywhere in Rails.

We are building a plugin for Rails to be used within iframe Facebook applications, and at one point we need to check if Rail's session id cookie as been set or not. By default, this cookie is named _myprojectname_session, what we need to find out is the actual name of the cookie itself. So if it's not set, we can do some redirects to ma...

Ruby Equivalent of ASP.NETs Application_Start?

I'd like to kick off a thread that wakes up every so many seconds to do some processing within a Ruby-on-Rails web app. In .NET, the logical place would have been to create a thread in the global.asax file and start it in Application_Start. Is there a similar paradigm for doing such things in RoR? Would this be done in the Application...

Rails ActiveRecord::find Join statement issue

Why does the following rails statement User.find(:all, :joins => [:roles,:roles_users], :conditions => { :roles => { :name => 'subscriber', :authorizable_id => self.id, :authorizable_type => self.class.to_s }}) Translates into this (with 2x the ...