ruby-on-rails

Passing :locals argument to partial rendered by link_to_remote

From the documentation for link_to_remote The result of that request can then be inserted into a DOM object whose id can be specified with options[:update]. Usually, the result would be a partial prepared by the controller with render :partial. For example, one would do this: <%= link_to_remote( "Some link text", :url => url, :...

Latest and accepted ajax techniques in Rails

What is the present state of Rails Ajax? What frameworks and technologies should one use when working with Rails now? Rails seems to evolve so rapidly that one might not be able to keep up. Is it prototype and RJS or something else? ...

How can I implement a semantic ontology in Ruby on Rails?

I'm working on a "twitter filter" - more to learn ruby on rails than anything else. The idea is that I use a semantic ontology to lookup a users interests. So if a user says they're interested in "sports" that means flag any tweets that discuss "sports" "golf" "football" and so on. I'd like to be able to expand it to any hierachial of t...

YUI Editor: How to paste as plain text?

I implemented the Yahoo Rich Text Editor (YUI Editor) in a Rails application using the YUI_Editor Plugin. If I copy/paste text out of a PDF into a YUI-Editor-enhanced-TextArea (YEETA :)) it does not only copy the text but also the formatting of it. How do I configure the YUI Editor to remove all formatting of text pasted into the YEETA...

MySQL not using indexes with WHERE IN clause?

I'm trying to optimize some of the database queries in my Rails app and I have several that have got me stumped. They are all using an IN in the WHERE clause and are all doing full table scans even though an appropriate index appears to be in place. For example: SELECT `user_metrics`.* FROM `user_metrics` WHERE (`user_metrics`.user_id...

How to track online users in Rails?

This was always a problem for me, as rails doesn't have some mechanisms for session tracking like java frameworks do, what methods do you use to track who is currently logged on your site? I use a simple method by setting up last_visited field with current time every time user clicks somewhere on the site, and then checking for users whi...

check_box checked by default in rails 1.2.3

How can I make a check box default to being "checked" when it is initially displayed? I've not found a "Rails" way to do this (that works) so I did it with JavaScript. Is there a proper way to do this in Rails? I'm using Rails 1.2.3. ...

Rails: submit (via AJAX) when drop-down option clicked

What is the easiest and most graceful way to auto-submit an AJAX form when a drop-down box's option is selected? I'm creating an administration page where the admin can modify user permissions (where "permissions" is stored as an integer), and I would like the "permissions" field to be a drop-down box that automatically submits and updat...

First Activerecord model missing attributes/methods

I'm having a very strange problem. I'm getting a collection of Rails ActiveRecord models back from the database but the first model in the collection does not have the model attributes/methods, just the standard ActiveRecord base methods. The rest have all the attributes. And it's only doing this on my production debian server using Pas...

Setting the HTTP_REFERER in a global before(:all) in Rspec

In order to avoid adding request.env["HTTP_REFERER"] = '/' to a before block on every controller_spec file I create, I have tried to add this to the global config (in spec_helper.rb) config.before(:each) {request.env["HTTP_REFERER"] = '/'} The problem is, I get the following error: You have a nil object when you didn't expect it! ...

Where can I find advanced Ruby on Rails tutorials?

I'm working creating rails application and wondered where I can find good tutorials on how to work with rails. I used this blog that I thought was great in starting to learn rails: http://fairleads.blogspot.com/2007/12/rails-20-and-scaffolding-step-by-step.html I have just started working with rails and would like to learn more advanc...

While installing redbox plugin to rails why does it say Plugin not found ?

When I try to install redbox plugin although everything gets installed, a last line says plugin not found. Why is that ? script/plugin install http://svn2.cvsdude.com/craigambrose/plugins/redbox + ./README + ./Rakefile + ./images/redbox_spinner.gif + ./init.rb + ./install.rb + ./javascripts/redbox.js + ./lib/redbox.rb + ./lib/redbox_hel...

Rails task: script/runner or rake?

For ad hoc Rails tasks we have a few implementation alternatives, chief among which would seem to be script/runner some_useful_thing and rake some:other_useful_thing Which option should I prefer? If there's a clear favourite then when, if ever, should I consider using the other? If never, then why would you suppose it's still prese...

Under what cirumstances would I need eruby if I'm just doing Ruby programming

As I understand it, eruby is like erb - it lets you stick ruby code into HTML. If someone is using Rails, more than likely they would use erb or Haml. But if I'm not using Rails, under what cirumstances would I need eruby if I'm just doing Ruby programming? I guess I don't understand why someone would need to be outputting HTML if th...

How can I format the value shown in a Rails edit field?

I would like to make editing form fields as user-friendly as possible. For example, for numeric values, I would like the field to be displayed with commas (like number_with_precision). This is easy enough on the display side, but what about editing? Is there a good way to do this? I am using the Rails FormBuilder. Upon investigation, I...

Rails: rake db:migrate *very* slow on Oracle

I'm using rails with the oracleenhanced adaptor to create a new interface for a legacy application. Database migrations work successfully, but take an incredibly long amount of time before rake finishes. The database changes happen pretty quickly (1 or 2 seconds), but the db/schema.db dump takes over an hour to complete. (See example mi...

Best way to create custom config options for my Rails app?

I need to create one config option for my Rails application. It can be the same for all environments. I found that if I set it in environment.rb, it's available in my views, which is exactly what I want... environment.rb AUDIOCAST_URI_FORMAT = http://blablalba/blabbitybla/yadda Works great. However, I'm a little uneasy. Is this a go...

Find Methods in derived classes with ActiveRecord - Single Table Inheritance

Hello, I have a class that derives from ActiveRecord::Base. This class has a subclass that is differentiated in the database by a type id column. How do I make sure that all the inherited active record functions in the derived classes append the type_id column to the conditions hash on any queries that are executed by the derived class?...

Directory to store cached files in Rails?

I am generating some large files in my Rails application. Fortunately, they only need to be generated once. I would like to save these files to disk so that I don't have to generate them again. Which directory in my Rails application is the most appropriate place to put application generated files? Thanks! ...

single sign on between Vbulletin and rails applications

we have a lot of users on a VBulletin forum. now i want write few more apps on rails for the same userbase. Until now all the authentication and session management is being taken care of by VBulletin. What is the best way to provide SSO for my users both onVBulletin and on the rails apps i am writing ...