ruby-on-rails

How do I remove duplication in shoulda tests?

Here is what I have: context "Create ingredient from string" do context "1 cups butter" do setup do @ingredient = Ingredient.create(:ingredient_string => "1 cups butter") end should "return unit" do assert_equal @ingredient.unit, 'cups' end should "return a...

How to read a barcode from an image

I'm seeking a library, technique or advice on how to read an EAN-13 barcode from an image (including ISBN,and ISSN encodings). The image would come from a mobile phone or webcam, so resolution may be quite poor and not well aligned. I'm specifically interested in something that could be used from ruby on rails, but answers for other lan...

What are the possible causes of a CGI::Session::CookieStore::TamperedWithCookie exception in rails

I am receiving the expcetion CGI::Session::CookieStore::TamperedWithCookie after changing the config.action_controller.session.secret setting on an app (as part of preparation to full deployment. Am I right in assuming that changing the secret while testers have cookies set is the cause of this, and what other cause could there be (bot...

How do I handle data which must be persisted in a database, but isn't a proper model, in Ruby on Rails?

Imagine a web application written in Ruby on Rails. Part of the state of that application is represented in a piece of data which doesn't fit the description of a model. This state descriptor needs to be persisted in the same database as the models. Where it differs from a model is that there needs to be only one instance of its class a...

no respond_to block in edit action (generated with scaffold)?

Does anyone know why there is no respond_to block for generated edit actions? Every other action in typical scaffold controllers has a respond_to block in order to output html and xml formats. Why is the edit action an exception? I'm using the latest version of Ruby on Rails (2.1.1). ...

Uploading files in Ruby on Rails

I have a web application that needs to take a file upload from the user and upload it to a remote server. I can take input from user to server fine via file_field, but can't seem to work out the next step of uploading from server to remote. Net::HTTP doesn't do multipart forms out of the box, and I haven't been able to find another goo...

Getting started with rails? Must have gems?

I'm starting work on a project using Rails, but I'm waiting for the 3rd edition of the pragmatic rails book to come out before I purchase a book. Anyway, my question is a bit more pointed than how do I get started... What are some of the must have gems that everyone uses? I need basic authentication, so I have the restful authenticati...

Rails Tests Fail With Sqlite3

Hello all, I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error: SQLite3::SQLException: cannot rollback - no transaction is active This error is crippling my ability to test my appl...

Which PHP framework is closest to Ruby on Rails? CakePHP? CodeIgniter?

I'm going to be switching back and forth between Ruby on Rails projects and some as-of-yet undecided PHP MVC framework projects. Which of the PHP MVC frameworks out there (CakePHP, CodeIgniter?, others?) is most similar to Ruby on Rails in that the most conventions, locations, workflows, etc are preserved? I'm looking for the similar...

What's the best way to implement ACLs to a Rails application?

I just wanted to compare different solutions used when implementing ACLs in Rails. ...

What should I do with the vendor directory with respect to subversion?

So I have a problem. I checked in my frozen gems and rails even though you aren't supposed to do that. I figured it was easy and wouldn't be that big of a deal anyway. Well, later I updated rails and in doing so deleted all the .svn files in the vendor/rails directories. I have heard that what I really should do is just do something ...

The Rails Way - Namespaces

I have a question about how to do something "The Rails Way". With an application that has a public facing side and an admin interface what is the general consensus in the Rails community on how to do it? Namespaces, subdomains or forego them altogether? ...

Rails performance analyzers

What are the preffered plugins for monitoring and analyzing the performance of a Rails app? I'm looking for both database/query analyzers and the rest of the stack if possible, though not necessarily all in one plugin. Which ones do you recommend? ( Bonus points for free ones :) For example, this one looks spify. ...

User Monitoring in Rails

Hi We have an app with an extensive admin section. We got a little trigger happy with features (as you do) and are looking for some quick and easy way to monitor "who uses what". Ideally a simple gem that will allow us to track controller/actions on a per user basis to build up a picture of the features that are used and those that ar...

Updating server-side progress on Rails application

I want to upload and then process a file in a Ruby on Rails app. The file upload is usually quite short, but the server-side processing can take some time (more than 20 seconds) so I want to give the user some indicator - something better than a meaningless 'processing...' screen. I'm trying to use the following code in the view <%= p...

Best way to store constants referenced in the DB?

In my database, I have a model which has a field which should be selected from one of a list of options. As an example, consider a model which needs to store a measurement, such as 5ft or 13cm or 12.24m3. The obvious way to achieve this is to have a decimal field and then some other field to store the unit of measurement. So what is th...

Which version of rails should I start with?

I have been dabbling with Ruby for some time now and also was thinking of learning RoR they released a new version for it. :) So now should I start learning RoR v1.2 or v2.x especially keeping the following in mind I couldn't find any great free books/in-depth tutorials on RoR 2.x yet I want to learn RoR with the eventual goal of doin...

Use of Migrations in Ruby on Rails

I would like to confirm that the following analysis is correct: I am building a web app in RoR. I have a data structure for my postgres db designed (around 70 tables; this design may need changes and additions during development to reflect Rails ways of doing things. EG, I designed some user and role tables - but if it makes sense to us...

Supporting URLs like /similar-to-:product in Ruby on Rails?

I have been trying to use routes.rb for creating a URL /similar-to-:product (where product is dynamic) for my website. The issue is that routes.rb readily supports URLs like /:product-similar but doesn't support the former because it requires :product to be preceded with a separator ('/' is a separator but '-' isn't). The list of separat...

Rails Caching Log Level

With the new caching options in Rails 2.1 i get nice entires in my log along the lines of Cached fragment hit: views/homepage (0.16549) However they are logged at the :debug level, which is the same level as the SQL output. I want to be able to disable the SQL output, and still see the cache info. How can I do this ...