ruby-on-rails

Anonymous users in Rails -- security considerations?

I'm looking at implementing some form of anonymous user system in Rails. I need to let people do things (creating records, looking at what they've created, etc), without actually creating an account. Once they create an account, everything persists without risk of losing it by clearing cookies or something. Right now, I'm thinking it's ...

Rails: submitting a form with multiple objects

I'm creating a Rails application, and I've hit a bit of a snag. I want a "create new record for DataType1" form that not only creates a new row for DataType1, but also inserts up to four new rows for DataType2. I know all about fields_for, but my problem is that I need to submit up to four DataType2s, and the only connection they have t...

How can I dynamically add a method to the Math class in Ruby on Rails?

I am trying to add the following method to the Math class in Ruby on Rails: class Math def self.round_with_precision(number, precision) scalar = 10.0 ** precision number = number * scalar number = number.round number = number / scalar return number; end end I then added the following to my environment.rb: requ...

Rails 1.2 "service is deprecated"

My app is on rails 1.2.6 and I wish to upgrade it to 2.2 I see this warning in the logs: DEPRECATION WARNING: service is deprecated and will be removed from Rails 2.0 See http://www.rubyonrails.org/deprecation for details. (called from .... application.rb:14) The line is question is service :notification Can somebody tell me what ser...

Ruby on Rails Ajax rubberband

I want my users to be able to do a rubberband selection in a image for a Ruby on Rails application. Has anyone seen any good plugins that do this or make it easy for me to implement it? ...

Ruby Object Member Access: How's that Done?

Having looked at this question: http://stackoverflow.com/questions/354547/print-ruby-object-members I have a related issue. I'm relatively new to Ruby, so this is hopefully blindingly obvious. I have what I believe to be a Ruby object, generated from the MIME::Types library. I'm looking to get a simple file type for a particular file. ...

Rails form validation conditional bypass

I have a rails model that validates uniqueness of 2 form values. If these 2 values aren't unique the validation errors are shows and the "submit" button is changed to "resubmit". I want to allow a user to click the "resubmit" button and bypass the model validation. I want to do something like this from the rails validation documentat...

Best way in MySQL or Rails to get AVG per day within a specific date range

Hey guys, I'm trying to make a graph in Rails, for example the avg sales amount per day for each day in a given date range Say I have a products_sold model which has a "sales_price" float attribute. But if a specific day has no sales (e.g none in the model/db), I want to return simply 0. What's the best way in MySQL/Rails to get this ...

Links to AJAX calls do not work

Hi all i am writing a Rails application and i include some link_to_remote links The generated code is <a href="#" onclick="new Ajax.Request('/b10/categories/games?category=Action', {asynchronous:true, evalScripts:true}); return false;">Test</a> That works perfectly fine on Safari and Firefox but when i try to click the link on IE7 and...

PostgreSQL replication strategies

Right now we are using PostgreSQL 8.3 (on Linux) as a database backend to our Ruby on Rails web application. Considering that on PostgreSQL database we actively use row level blocking and PL/PGSQL, what can we employ to secure our data -- I mean tools, packages, scripts, strategies -- to successfully replicate the database and build mul...

Apache's AuthDigestDomain and Rails Distributed Asset Hosts

I've got a server I'm in the process of setting up and I'm running into an Apache configuration problem that I can not get around. I've got Apache 2.2 and Passenger serving a Rails app with distributed asset hosting. This is the feature of Rails that lets you serve your static assets from assets0.example.com, assets1, assets2, and so on...

Rails: modify form parameters before modifying the database

I'm working on a Rails app that sends data through a form. I want to modify some of the "parameters" of the form after the form sends, but before it is processed. What I have right now {"commit"=>"Create", "authenticity_token"=>"0000000000000000000000000" "page"=>{ "body"=>"TEST", "link_attributes"=>[ {"action"=>"Foo"...

Multiple links on a Rails view that each perform different actions - how best to handle this?

One of the things I'm doing includes several links on the show view. For instance, I have a link (or button) for "Accepting", and another one for "Rejecting". Click on Accept, and the model updates the is_accepted field as true, click on Reject, and the is_accepted field is false. Now, how best do I handle this? In ASP.NET, I would have...

Sending binary data to (Rails) RESTful endpoint via JSON/XML?

Hello there, I am currently putting together a rails-based web application which will only serve and receive data via json and xml. However, some requirements contain the ability to upload binary data (images). Now to my understanding JSON is not entirely meant for that... but how do you in general tackle the problem of receiving bina...

Scaffolding for PHP

Is there any thing in PHP to create basic scaffold, like in Rails? EDIT: I need something to prototype quickly.. ...

How would you build this daily class schedule?

What I want to do is very simple but I'm trying to find the best or most elegant way to do this. The Rails application I'm building now will have a schedule of daily classes. For each class the fields relevant to this question are: Day of the week Starting time Ending time A single entry could be something such as: day of week: Wed...

Are there any good googlemaps plugins for rails?

There are some good geocoding plugins (e.g. geokit) but can you recommend a googlemaps plugin for "the view" in rails? I used YM4R/GM before but I don't know if its still up to date... ...

Elegantly selecting attributes from has_many :through join models in Rails

I'm wondering what the easiest/most elegant way of selecting attributes from join models in has_many :through associations is. Lets say we have Items, Catalogs, and CatalogItems with the following Item class: class Item < ActiveRecord::Base has_many :catalog_items has_many :catalogs, :through => :catalog_items end Additio...

What's the best way to compile Ruby from source on 64-bit RedHat Linux

On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source. I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires RubyInline. There seems to ...

XML File as database?

Is it possible to use single XML file for Ruby on Rails as an ActiveRecord database? ...