ruby-on-rails

Help with collection_select

The following produces a working select drop down that pulls from my user model: <%= f.collection_select(:user_id, @users, :id, :firstname, options ={:prompt => "Select a User"} %> I also have a column :lastname. I am trying to populate the select with something like :firstname + " " + :lastname This obviously fails if I just stick ...

Localized search with rails using acts_as_solr

I've a Rails 2.3 site with versions both in spanish and english, I am using translated_model. I am using acts_as_solr for full text search using multi_solr_search to return results from various models. I need to the search feature available both in spanish and english, how can I restrict the search to certain fields depending on the I1...

Rails 2.3 Updating multiple objects at once

I have a small app that has an edit form with multiple rows in a form. I followed the advice in the rails way book, page 364-365 and it worked perfectly. I am trying to update the app to run in 2.3 and the method described is now broken. The models are Course has many Books Book has many Courses Order belongs to course, books The contr...

Does map.namespace falls back in case if there is no matching controller?

Today I am observing a peculiar behavior in my rails app. I have defined the following route in routes.rb map.namespace :admin do |admin| admin.resources :users end and when I use rake:routes, I see the following routes as expected: admin_users GET /admin/users {:action => 'index, :controller => 'admin/users'} .... .... which are...

FF 3.5, firebug "breaks" sIFR3...

I have sIFR3 working nicely, but whenever I open Firebug in FF 3.5, any attempt to inspect the page breaks? sIFR3. The page reverts to it's non-sIFR3 text. Not sure what I'm missing. Updated* You'll notice the same behavior on one of the sample sites listed on the sIFR3 wiki: http://www.lightweb.pl/ ...

Rails, RESTful routing, and pluralization

I am struggling with the pluralization of the RESTful route generation in Rails 2.3.2. Specifically, I have a resource called sitestatus. This resource really is uncountable (deer is deer, not deers). When I specify it as uncountable in an intializer, I get some helpers, but the sitestatuses_path is unavailable (which would make sense)....

:foo => self.controller_name.to_s + "_path" does not return the path

Hello, Please look at the two examples below: irb(#<ActionView::Base:0x2863d58>):030:0> paintings_path => "/some-nice-alias-path" irb(#<ActionView::Base:0x2863d58>):029:0> self.controller_name.to_s + "_path" => "paintings_path" How do I return the path instead of the string? I need to call the controller path from my application he...

How to display reqs/sec in the rails logger log file?

The following log line in Rails log is common. Completed in 0.13425 (7 reqs/sec) | Rendering: 0.03244 (29%) | DB: ).0863 (65%) | 200 OK [htt://localhost/reviews] But in my development log file, I see the whole line except the (7 reqs/sec) part. Why this reqs/sec is not shown in my log?? How can I make it appear?? ...

Why do I have to restart apache to properly refresh a Ruby on Rails view in the browser?

I am trying to learn a bit of Ruby. I've installed Ruby on my Ubuntu machine and I am using apache. Everything works fine except to refresh a view I have to restart apache in the console and then hit ctrl-r, just pressing ctrl-r won't refresh the browser. Apparently there's some caching going on, but does it have to be that way i.e. is ...

Multiple Uploads to Amazon S3 from Ruby on Rails - What Background Processing System to Use?

I'm developing a Ruby on Rails application that needs to allow the user to simultaneously upload 16 high-quality images at once. This often means somewhere around 10-20 megabytes (sometimes more), but it's the number of connections that are becoming the most pertinent issue. The images are being sent to Amazon S3 from Paperclip, which ...

What's the best way to manage real-time configuration variables with Ruby on Rails?

I'm aware of YAML and plugins like rails-settings, but neither of these is useful for configuration settings that need to be changed in real time. For instance, say I have MAX_ALLOWED_REGISTERED_USERS set at 2000, but I want to up it to 2300. With a typical "configuration" or YAML solution, this would involve changing a config file and ...

Where's the best place to define a constant in a Ruby on Rails application?

In a Ruby on Rails 2.3.2 application, where is the best place to define a constant? I have an array of constant data that I need available across all the controllers in my application. ...

Complex forms with ruby on rails

I need the form that will edit the array of entities and their related entities(one to many). Like this: Person has many Orders. Form for array of People with their orders. What rails API can be used to build this form? Please give a code sample. ...

How to be good at Ruby on Rail

If I want to be good at Ruby on Rail, what is the good way to reach it? Which resource I should read? How Can I test myself that I good at it and what level am I? ...

Rails. How do I extend Authlogc with roles?

Hello, I am using Authlogic for my user authentication, and would like yo add roles to my users - Need security check from model's and controller's current_user.has_role?('admin') etc There is a lot of role based plugins out there, but I not sure which when to use with Authlogic. Does anyone what works best with Authlogic? (if any..)...

Captcha Implementation in ROR

Do I need to create a database table to implement captcha on a registration form? ...

Ruby on Rails - Share one method with 2 models

I have the following module module SharedMethods # Class method module ClassMethods # # Remove white space from end of strings def remove_whitespace self.attributes.each do |key,value| if value.kind_of?(String) && !value.blank? write_attribute key, value.s...

I have a problem to round off the poll results to amount to 100%

I am developing a poll using ruby, but the answer that i get is incorrect, i am looking for the answers that will results in 100% but my answers are sometimes 101% or 99% and i am sure is the rounding off of my floats but i just can get them right because without the rounding off the answers are very long floats. my code of calculating t...

Ad/Banner Management/Rotation for Ruby on Rails?

Hi, I have a niche site that I'd like to sell banners for directly, rather than going through adsense. I need a system to manage the whole process: displaying ads and an administrative interface to manage them. It doesn't have to be anything terribly fancy, although open source is greatly preferred so that I can grow the system as nee...

Nil Reference when Update

I am trying to get Paperclip working with MiniExiftool. I finally wrote this: # Photo model belongs_to :user has_attached_file :picture after_picture_post_process :copy_exif_data private def copy_exif_data exif = MiniExiftool.new picture.queued_for_write[:original].path self.date = exif['date_time_original'] ...