ruby-on-rails

Using embedded Derby with JRuby on Rails.

Attempting to use JRuby 1.2.0 and Rails 2.3.2 with an embedded Derby database. I've copied derbytools.jar and derby.jar to $RUBY_HOME/lib, yet rake db:migrate still gives: The driver encountered an error: cannot load Java class org.apache.derby.jdbc.ClientDriver Aaaand... I played a hunch and figured it out. So, I'll post this...

Web front end caching best practices for site?

Summary As I'm looking on stackoverflow and around the net, I find that there is a general lack of good documentation on best practices for caching a high performance site that uses sessions. It would be helpful if we can share some ideas around some basic building blocks particularly around caching. For the purpose of this discussion, ...

How to use multiple caches in rails?

I have a rails application where I would like to use both memcached and the file store cache, for different purposes. I want to use the file store cache to keep a large number of pages that don't change often (some not at all) - i.e. page caching - and use memcached for everything else (action and DB caching etc). The reason is that the...

Netbeans and Rails: Is there a way to make the Run option in netbeans also start thinking_sphinx?

I don't want to keep sphinx running all the time on my dev machine. I'd like a way to automatically execute rake thinking_sphinx:start when I run my app via netbeans. Is there a way to do this [also - I am using Windows] Thinking sphinx needs to run as a separate process. ...

Rails: link_to_remote update doesn't render the view

Hi, I have a link_to_remote to render the edit action of an object. But all it does is update the Dom Element with this response try { } catch (e) { alert('RJS error:\n\n' + e.toString()); alert(''); throw e } My link looks like this: = link_to_remote t("txt.edit"), :update => dom_id(comment), :url => edit_comment_path(comment.id) ...

Rails: Correct routing for namespaced resources

In Rails 2.3, if you add a resource map to a namespace in your routes.rb, how do you make link_to (and form_for and all those) understand that it should get that namespaced controller instead of one in the root namespace? example: map.namespace :admin do |admin| admin.resources :opt_in_users end link_to @anOptInUser #should use link_f...

protect_from_forgery & Unobtrusive Javascript

Hi all, I have some javascript making an ajax call in my Rails site: $.ajax({type: "PUT", url: url, data: { dummy: data }, complete: function(data) {}}); When Rails gets it, it throws back an ActionController::InvalidAuthenticityToken Error. I'd like to keep the protect_from_forgery stuff in there, if possible... But I'm at a loss ...

Rails associations with the same models

I have two classes with the following associations: class Incident has_one :assignee has_one :technician class User has_many :incidents Note that the assignee and technician fields refer to objects of type User. How should these relationships be in the model? ...

Rails: Single table inheritance and find(:all) in parent

I understand how STI works, in that I have say a Post model that contains posts on a forum and several sub-posts like 'ordinaryUserPost' and 'adminUserPost' etc. Now, I want to define the same method in each of the sub-posts, but the method would do something different in each case, eg class Post < ActiveRecord::Base end class AdminUs...

Accessing User Password: Variable Scope in Rails

I'm writing a very simple mailing system for a Rails app. I'm using RESTful authentication. It's a fairly conventional setup, where I'm sending the same email when a user signs up and when a user forgets their password. I'm just having one problem that I can't seem to wrap my head around. I'd like to use the same email template for both...

Django or RoR

I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly. I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think ...

restful_authentication applied to only an action within a controller?

Hello, I have installed and implemented the plugin restful_authentication from technoweenie. My application is, for the most part, intended to be open, except for the case of say, writing a review. So I have a reviews_controller.rb, but the only time I want to care whether the user is logged in or not is when they are submitting a spe...

How do I handle date objects in ruby on rails forms?

I am using a rails helper that creates 3 select lists for the purpose of letting a user select a date. If I assign the helper a name, it sets all 3 select lists to have that name, and then only the last one goes through (it overwrites the previous). What I need to know is: What is the best way to take a set of 3 select lists (day, mont...

I am having difficulties with creating an equipment

I am creating an equipment and I have two actions in my equipment controller, new and create.. and I have two views which is new and a partial form.. I also have four tables.. which are equipments, equipment_types, equipment_locations, and equipment_management_informations.. The form looks like.. >= error_messages_for 'equipment' %t...

Renaming the created_at, updated_at columns of ActiveRecord/Rails

I want to rename the timestamp columns defined in timestamp.rb . Can the methods of timestamp.rb be overwritten? And what has to be done in the application that the module with the overwritten methods is used. ...

Ruby Rails Time.change not working as I would expect...I have checked the docs!

I have a form that contains one date element and 3 time elements. This is because 3 time events will occur on one date, and I don't want the user to have to input that date 3 times. On the server side, I would like to combine the one date with the 3 times to get 3 datetime objects. I was thinking I could just do something like: time_...

Rails with Memcache returning wrong cached object?

I have a fairly large Rails app, which uses memcached on a seperate server as its cache store. The problem is that I randomly get errors in the production environment which seem to indicate that memcached is returning an incorrect object. Examples: In this example, current_site is a helper method which accesses a method on the Site m...

AASM Gem broken by Rails 2.3.2?

Has anyone had any problems using the AASM state machine Gem with Rails 2.3.2? It was working fine for me but is now giving a NoMethodError: NoMethodError (undefined method `state' for #<Comment:0x25cb8ac>): /usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.5/lib/persistence/active_record_persistence.rb:231:in `send' /usr/local/lib...

Rails: Storing binary files in database

Using Rails, is there a reason why I should store attachments (could be a file of any time), in the filesystem instead of in the database? The database seems simpler to me, no need to worry about filesystem paths, structure, etc., you just look in your blob field. But most people seem to use the filesystem that it leaves me guessing that...

no such file to load -- openid/extensions/sreg

I'm running ruby 1.8.6 and rails 2.3.2 on Mac OS X 10.5.6. I'm trying to get ruby script/server to work... I've waded through mysql and imagemagick installation, and I'm now faced with the following error: => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31...