ruby-on-rails

Rails/AR find where habtm does not include

I have a Rails app with Users, and each user HABTM Roles. I want to select Users without a specific role. I have searchlogic at my disposal, and I'm lost. I've tried using a combination of conditions and joins and includes and what not, but I can't seem to nail it. This works: User.find(:all, :conditions => ['role_id != ?', Role[:admin...

Rails Subdomain Clustering

Hello all, I am about to be writing a Ruby on Rails app which will use sub-domains to authenticate users. We will have two types of accounts: user accounts domain accounts Users will thus be able to belong to multiple domain accounts using the same credentials. I hope to have the ability for a domain account administrator to be able...

How do I work with Time in Rails?

I've been pulling my hair out trying to work with Time in Rails. Basically I need to set all time output (core as well as ActiveSupport) to the server's local time -- no GMT, no UTC, etc. I've seen various posts relating to Time, but they usually involve someone's need to set it for each user. Mine isn't nearly as complex, I simply wa...

rack-jsonp not working for simple requests but works for .js calls in Rails 2.3

I am using Rails 2.3 and I decided to provide support for JSONP. Created a brand new application. Then ran script/generate scaffold User name:string This is my entire environment.rb RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), 'boot') require 'rack/contrib' Rails::Initializer.r...

Submitting a Rails form with jQuery and Ajax

EDIT: Figured it out so asking a related question. here's my Javascript jQuery.ajaxSetup({ 'beforeSend': function(xhr) { xhr.setRequestHeader("Accept", "text/javascript") } }) jQuery.fn.submitWithAjax = function() { this.submit(function() { $.post(this.action, $(this).serialize(), null, "script"); r...

solr sanitizing query

I am using solr with ruby on rails. It's all working well, I just need to know if there's any existing code to sanitize user input, like a query starting with ? or * ...

Rails param value with anchor appended?

Hi, The following link <%= link_to "Login to comment", :url => new_session_url(:return_to => request.request_uri, :anchor => 'commentForm'), :method => :get, :html => { :id => 'login_to_comment'} %> generates the following url: http://localhost:3000/session/new?return_to=%2Fnature_photos%2Fsdfds#commentForm and the parameters are ...

Rails 2.3.2.1 error with Litespeed 4.0.5

I just upgraded to Rails 2.3.2.1 running Litespeed web server 4.0.5 and get the below error. I think it has something to do with setting up the Rack preference (server = Rack::Handler::LSWS) but not sure how to do it. Also, I'm running the lateast ruby-lsapi [root@idev logs]# gem list ruby-lsapi ruby-lsapi (3.5, 3.3, 3.2) 2009...

JRuby, Rails, and FeedTool

Anyone using JRUBY on Rails with FeedTools? I'm getting the following error when I try to run FeedTools: NameError (undefined local variable or method `parser' for YAML:Module):. I've tracked the code down to monkey_patch.rb. It is bombing on the parser line, but I'm new to Ruby and Rails and couldn't debug it on my own. What's weird ...

Ideas for web application with external input and realtime notification

Hello everyone, I am to build a web application which will accept different events from external sources and present them quickly to the user for further actions. I want to use Ruby on Rails for the web application. This project is a internal development project. I would prefer simple and easy to use solutions for rapid development over...

Codeigniter vs Ruby on Rails

I'm new to development, and I'm getting into it as a hobby. (currently a student). I'm wondering what you guys and girls advise. There's greater support for PHP, I realize. But Ruby looks like it offers a great deal more flexibility...and it's prettier. This is a question from a noob, so if this is a bad question, please excuse me! ...

Rails: How do I create an instance of a class in a STI hierarchy by it's stored type?

Let's say I am using a STI pattern to persist several different subclasses of "Transaction," which subclasses "ActiveRecord" My subclasses might include "HighPriorityTransaction" and "LowPriorityTransaction" which rails will store in the table "transactions" with a "type" column. Each subclass has a different implementation of the befor...

What is the leading chat plugin for rails?

I currently have a hideous delay based chat app in my learning management system (rails based) but want to explore other options. The jabber approach seems cool, and there is can_has_chat, but on their google code page there is a notice about the potential for trouble with many sleeping mongrel instances. Doesn't seem like a good way to ...

What's the ideal error to raise when the url entered by the user is incorrect?

I have an action that searches records based on a url parameter. The url for the action looks something like this: http://domain.com/records/filter/&lt;filtercode&gt; If the user enters an incorrect filtercode, I would like to app to raise an error so that Hoptoad will report to error to me. render a 404 instead of a 500 in producti...

ActiveResource timeout not functioning

I'm trying to contact a REST API using ActiveResource on Rails 2.3.2. I'm attempting to use the timeout functionality so that if the resource I'm contacting is down I can fail quickly - I'm doing this with the following: class WorkspaceResource < ActiveResource::Base self.timeout = 5 self.site = "http://mysite.com/restAPI" end Ho...

Validate: Only letters, numbers and -

Hello, I would like to validate my users, so they can only use a-z and - in their username. validates_format_of :username, :with => /[a-z]/ However this rule also allows spaces ._@ Username should use only letters, numbers, spaces, and .-_@ please. Any ideas? Best regards. Asbjørn Morell ...

CMS for Ruby on Rails

Do you have a suggestion of a CMS writeten in Ruby on Rails. I need it for a corporate intranet. I am new to RoR, I am a PHP programmer, so it is better for me not to start from scratch. ...

Single sign on for rails apps in the same domain

I have 2 rails apps on the same domain. i want the single sign on feature to be added to them. i would prefer to maintain separate database for each app.. Can anyone please tell me how to do this? Thanks in advance, Ak ...

acts_as_nested_set and inheriting from parent node

I am using awesome_nested_set but I guess this applies to all the nested_set plugins equally. When I add a child I want that child to inherit some attributes from the parent. Sounds simple, it certainly is with acts_as_tree. The problem is you need to save the object before adding to the parent, so at least initially you end up with a r...

How to get the value of a datetime_select field with javascript in ruby on rails

Hi, I had a previous question that touched this topic (http://stackoverflow.com/questions/1131694/rails-how-to-get-value-from-another-field-when-executing-an-onchange-remote-func), but then I dugg a little deeper and realized that my problem is the datetime_select method. I have a textfield with onchange. In the onchange I need to get ...