ruby-on-rails

Remember me and restful_authentication

I have a rails application which uses the restful_authentication plugin. I have activated the "remember me" functionality but every now and then I am getting logged out. The problem is I can't see the pattern for when it happens. Sometimes it works in the development environment but not in production. Sometimes it works in Firefox but ...

How to chain AJAX calls in Rails? A series of calls to be executed, depending on the result of the first call.

I've a AJAX call, that pulls some initial data. Based on this data, I want to fire a series of AJAX calls, updating different parts of the page. It can be done using JS, with the XMLHttpRequest and onreadystatechange, checking for the status. If the first call is done and the response is 200, I can just fire a series of AJAX calls. H...

link_to_remote not updating div

I'm using link_to_remote to update a div asynchronously, but it does not work. I have to refresh the page in order to see the change. I use this to generate the links. http://ruby.pastebin.com/m1d83be81 "padding-left:30px", :display => "table-row" ) do %> { :success => 'entry_' + entry.id.to_s}, :url =>{ :controller =>...

Should I freak out about Rails deprecation warnings?

When dealing with any framework with which you are not 100% familiar, I've found it advisable to attempt to understand and clean up any extraneous warnings, if only so that you have a better chance of noticing real errors when they occur. The one I've been getting lately has been: DEPRECATION WARNING: @model will not longer be implici...

Why do test:units and test:functionals insist on running in development environment?

I'm trying to test some environment-specific settings (middleware to be specific, but it doesn't seem to matter), but I'm having trouble getting the tests to run in the correct environment. The symptoms: If I run ruby test/unit/my_test.rb, all is fine because the first thing it does is require test/test_helper.rb, which sets the enviro...

How do I use domain objects from middleware with cache_classes off?

In the rails development environment, cache_classes is off so you can modify code under app/ and see changes without restarting the server. In all environments, though, middleware is only created once. So if I have middleware like this: class MyMiddleware def initialize(app) @app = app end def call(env) env['model'] = M...

Basic Rails Question: Building Data Over Several Pages

All Rails expert sites say not to store ActiveRecords in the Session. However, I have a multiple-field ActiveRecord object that spans several pages. The code I'm trying to clean up used hidden fields to pass the data forward, which seems like a bad idea (user can tamper for one thing). What's the typical, or good, way to divide up a mode...

Converting special characters in rails

Is there a built in way to convert special characters in rails from ASCII to html? I saw 'htmlentities' but saw it is form a while back and wondered if there was anything more generic lately? ...

Rails, MySQL and Snow Leopard

I upgraded to Snow Leopard using the disc we got at WWDC. Trying to run some of my rails apps now complains about sql (in /Users/coneybeare/Projects/Ambiance/ambiance-server) !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. Importing all sounds in /Users...

A good example of Ubuntu email handling for a rails project

Having issues with a rails 2.2.2 app running on a VPS (Ubuntu 8.10): looking for github repos, posts, anything that covers the right way of setting up email processing. For example, should it be using sendmail or smtp? ...

Diagnosing Rails Application Hang on Element Update

In the course of building a rails application to help small hotels' manage bookings, I'm encountering a strange application hang. Building the reservation works fine; adding guests, assigning them to rooms, etc, without issue. However, when the merchant goes to 'confirm' an inquiry, Mongrel hangs me out to dry. The index page for reserv...

(RAILS) Looping a Custom Rake every 2 mins, Bad Idea? Better way to implement?

I've currently created a custom rake file that does the following: 1.) Checks an External Feed for "NEW" Items 2.) For each new item in the feed array,it updates my Database with a new record 3.) I've currently got it on a WHILE loop. The while loop has an (@loopcheck) instance variable that is set to true initially, and if any ex...

Checking passwords against word database on server or use a web service?

If I want to check passwords in my application for the inclusion of English words, should I store a database of English words locally (is there a free database?) or is there a (free) web service I can use to check them remotely? Ideally I would check the words using an Ajax call but I don't want to pass the entire English dictionary by...

How do you set the language in Rails?

Hi, I am trying to use i18n in rails. I want the language to be set first from params[:locale] (probably already in the url) then from the browser http header and lastly from the default_locale. Everything is fine. Now the problem starts, when I want to add a dropdown list to allow the user to change the locale. How do I force the page t...

How do you talk to a BerkeleyDB database from Ruby or Ruby on Rails?

I have no idea how I would set up a BerkelyDB database in a Ruby or Rails project. Does anyone have any experience configuring one, that they could talk about? Maybe using ActiveRecord or Datamapper? ...

How do I set a unique ID for checkboxes in a multi-record Rails form?

I've set up a Rails form roughly following the instructions in this Railscast. Here's the code for the form: <% form_tag complete_todos_path, :method => :put do %> <ul> <div id="incomplete_todos"> <% @incomplete_todos.each do |todo| %> <%= render :partial => todo %> <% end %> </div> </ul> <%= submit_tag...

(Ruby, Rails, Javascript) Managing nested models using javascript windows, etc...?

Hi All, I'm currently developing a Rails app with 4 nested models (as per THIS POST). I've considered using javascript to manage them all on one page. It appears doable (as do many things in Rails), however, it doesn't come highly recommended. That said, I'm looking to manage via proxy pages. Currently the model structure is as foll...

Comparing dates in rails

Suppose I have a standard Post.first.created_at datetime. Can I compare that directly with a datetime in the format "2009-06-03 16:57:45.608000 -04:00" by doing something like: Post.first.created_at > Time.parse("2009-06-03 16:57:45.608000 -04:00") Edit: Both fields are datetimes, not dates. ...

How can I emulate a SO-style tagging system in Rails?

I think that the SO-style tag system works very well and would like to emulate it in an app I am building with Rails. I am especially enamored by the way the tag entry box looks up the top 5 tag matches as you type. Is there a built-in function or plug-in that would do something similar for me in Rails? Otherwise, what would be a good...

Rails nested resources with strange path?

I have a typical artist has_many songs model and I'm trying to set up the nested resource in Rails. My routes.rb looks like this: map.resources :artists do |artist| map.resources :songs end This works fine for the artist paths, but when I want to link to the songs controller, like this: <%= link_to artist.name, artist_songs_path(...