ruby-on-rails

What rails plugins are good, stable and *really* enhance your code?

Anyone have a list of rails plugins that are both stable and give you enough functionality to be worth the extra effort of supporting? Edit: I am mostly interested in the best, most complete list of plugins so I can use it the next I'm starting a rails app. I don't currently need a particular plugin. ...

In Rails, how can I ensure users enter form data in correct order?

I have a Rails app with a model whose fields are dates which are checkpoints for a certain process. I want to prevent the user entering a date for the nth checkpoint until they have entered a date for the (n-1)th. Obviously, I can validate in the model to make sure that no dates are missing (and that dates are in chronological order) b...

Legacy Schema and dynamic find (Ruby on Rails)

Hello, I'm trying to put a rails face on a legacy database. It is an old Sybase 11 database installation. I've gotten an ODBC connection working that uses unixODBC and FreeTDS to work. I'm also using the activerecord-odbc-adapter gem. I've had to use set_table_name and set_primary_key to make it work so far. However, none of the dynami...

Deploying Ruby on Rails with Apache and Mongrel

Hi Folks, I'm fairly new to ruby on rails and web development. Here is my setup which I followed from this link http://tonyrose023.blogspot.com/2007/01/multiple-rails-apps-with-mongrel.html I run multiple rails applications on Apache2 with Mongrel clusters. http://services.abc.edu/app1 http://services.abc.edu/app2 http://services.abc.ed...

Persistence in Ruby on Rails?

Is there a way to persist data between page loads in RoR? I guess I'm looking for something like memcached, but without the overhead of TCP/IP. For example, PHP has APC. The ideal solution would be something in memory. ...

Session isn't passing over domain

In my rails app, when I log in at the www.site.com address, I am logged in just fine. Although without logging out, I go to the site, http://site.com I am logged out, but still logged in at the www.site.com address if I go back. I can't find anything to set in my environment variables, any idea as to how to keep this session across all ...

Is it necessary to unit test ActiveRecord validations?

Is it necessary to unit test ActiveRecord validations or they are well-tested already and hence reliable enough? ...

inheritance in controllers

Hi all, I use inheritance in my model. An event has different types: Event < activity Event < training Event < game I want to set session data to every event type like game.user_id = session[:user_id] training.user_id = session[:user_id] activity.user_id = session[:user_id] I want to avoid writing @game.user_id = session[:user_id]...

How do you incorporate SSL for secure local development with InstantRails?

I'm using InstantRails (on Vista), and I'm at the stage where I'm looking to integrate a Rails app with PayPal (recurring billing via web payments standard - no ActiveMerchant needed). What is the best step-by-step process for enabling HTTPS for my local development/testing purposes? I'm using the default Mongrel/Apache setup that comes...

Using print instead of sprintf with %s and % and multiple string substitution arguments

In the following ruby code, the output becomes: "x y" x = "x %s" y = "y" z = "z" print x % y %z The %z is ignored. I want the output to be "x y z". To understand the possibilities and limitations of the syntax of Ruby, I want to use only the print command and the %s and % flags. I know how to do this using sprintf but I want to kno...

How do I set HTTP_REFERER when testing in Rails?

I'm trying to test a controller and I got this error. I understand the error, but don't know how to fix it. test: on CREATE to :user with completely invalid email should respond with redirect (UsersControllerTest):ActionController::RedirectBackError: No HTTP_REFERER was set in the request to this action, so redirect_to :back co...

print + each() block - why does joining not work?

I'm expecting this output: output:xyz But if I type the following: a = ["x", "y", "z"] print "output:" + a.each {|i| print i}.to_s Why do I get an 'xyz' before the word output as well as after it? xyzoutput:xyz ...

Hide a DIV [Rails]

Hiding a DIV would be easy enough in Javascript, but is there some Rails-y way to do it? I can think of some ways to do it by calling Javascript from a partial (.erb), of course, but I'd prefer not to write any Javascript at all. Possible? Edit: The page is loaded and I would like to hide the DIV after (well, on) an Ajax call, so I'm in...

undef - Why would you want to undefine a method in ruby?

I've never seen undef - or any thing else that allows you to undefine a method - in any other programming languages. Why is it needed in Ruby? EDIT: I'm not arguing that there is anything wrong with this. I just don't understand the purpose of defining methods at runtime? What's the purpose of that? How is it used? I've never done this ...

Rails inline Javascript and Best Practices

I'm kinda new to using Rails, and an app I am working on is progressing well - however I'm looking though the generated HTML and noticed things like... <script type="text/javascript"> //<![CDATA[ Droppables.add(...); //]]> </script> Sprinkled around the HTML, which of course matches up with places where I use: <%= drop_receiving_elem...

"Warm Up Cache" on deployment

I am wondering if anyone has any plugins or capistrano recipes that will "pre-heat" the page cache for a rails app by building all of the page cached html at the time the deployment is made, or locally before deployment happens. I have some mostly static sites that do not change much, and would run faster if the html was already written...

Where to place Git repository

Hi, I just started using Git and I want to know if this is the right way of using it. I started a Rails app with: rails newapp Then I did: cd newapp git init git add . git commit -a So is it "right" to init my git inside my working directory? ...

Ruby on rails link_to syntax

After following a tutorial Ive found. Im now redoing it again, without the scaffolding part, to learn it better. However, editing my \app\views\home\index.html.erb to contain: <h1>Rails test project</h1> <%= link_to "my blog", posts_path> I get an error: undefined local variable or method `posts_path' for #<ActionView::Base:0x4e1d95...

Create web application with ajax from the begining or add ajax later?

I'm working on my first Ruby on Rails aplication and it's quite big (at least for me ;) - database has about 25 tables). I'm still learning Ruby and Rails and I never wrote anything in Javascript nor Ajax. Should I add Ajax to my application from the begining? Or maybe it will be better to add it latter? Or in the other words: is it (r...

What does error occurred while evaluating nil.dependencies mean?

I'm running ruby on rails v2.2.2 and when I run rake gems I get this error. $ rake gems --trace - [I] settingslogic rake aborted! You have a nil object when you didn't expect it! The error occured while evaluating nil.dependencies /vendor/rails/railities/lib/rails/gem_dependency.rb:77:in `dependencies' ...