ruby-on-rails

Why use Ruby instead of Smalltalk?

Ruby is becoming popular, largely from the influence Ruby on Rails, but it feels like it is currently struggling through its adolescence. There are a lot of similarities between Ruby and Smalltalk -- maglev is a testament to that. Despite having a more unusual syntax, Smalltalk has all (if not more) of the object-oriented beauty of Ruby....

Rake aborting with error

Trying to setup the exception_logger plugin on a production server. Everything worked fine on the dev machine. Trying to rake db:migrate on the prod server and i get this error: rake aborted! no such file to load -- pagination What am i missing? ...

Can I run LAMP and Rails from the same Apache instance?

We have a RedHat box with Apache2, PHP5 and MySQL 5 for much of our development. Now, we have a Rails client, and we need to set up a Rails app on the same server. Can we install Ruby and the Rails framework with the same Apache, or should we avoid this? Why or Why not? Is it possible to direct subdomains to either PHP or Ruby in the ind...

How to query a model based off the controller name

I've been refactoring my models and controllers in an effort to remove code duplication, and so far it seems to be all peachy creamy. Currently I've got a bit of code that is common to two of my controllers, like so: def process_filters # Filter hash we're going to pass to the model filter_to_use = {} # To process filters, we firs...

How do I create the migrations for a legacy database?

I am currently developing a Rails application using a database that was designed before I was aware of Rails existence. I have currently created some migrations to add some new tables and new columns to existing tables. I would like to have the migrations to recreate the full database. Which steps should I follow? Should I create all t...

Best Role-Based Access Control (RBAC) database model

What is the best database schema to track role-based access controls for a web application? I am using Rails, but the RBAC plugin linked by Google looks unmaintained (only 300 commits to SVN; latest was almost a year ago). The concept is simple enough to implement from scratch, yet complex and important enough that it's worth getting r...

Deploying binary gems to a different platform

I have a Rails app that I need to deploy. Here are the facts: The app was developed on Windows and requires Windows binary gems The app is to be deployed onto an Open Solaris shared server (Joyent) I do not have permissions to install gems on the server For the non-binary gems, I can simply do a rake gems:unpack locally and then upload...

What is the best way to read the Rails session secret?

I would like to access the Rails session secret programmatically (I am using it to generate a sign-on token). Here's what I've come up with: ActionController::Base.session.first[:secret] This returns the session secret. However, every time you call ActionController::Base.session it adds another entry to an array so you end up with so...

Rails: page protection redirection problem with link_to_unless_current

When using before_filter :login_required to protect a particular page, the link_to_unless_current method in the application layout template renders the "Login" link for the login page as a hyperlink instead of just text. The "Login" text/link problem only occurs when redirected to the Login Page via the before_filter machinery, otherwis...

How can I use different RJS templates from the same rails controller?

I have a controller method that returns a list for a drop down that gets rendered in a partial, but depending on where the partial is being used, the RJS template needs to be different. Can I pass a parameter to the controller that will determine which RJS gets used? Here is the controller method, it is very simple: def services res...

Where can I find good examples of Rails applications?

I would like to get source for a small, well written rails app to modify and "play with" as I learn how to program. I have found hundreds of open-source apps, but I don't know which are any good. Any suggestions? ...

phpBB equivalent for Ruby on Rails

I'm looking for Forum software similar to phpBB, but intended to run within a RoR application. I'm looking for a list of sites, along with one recommendation for which one is currently the ideal choice (ease of setup, simplicity, aesthetics). ...

Rails check if yield :area is defined in content_for

I want to do a conditional rendering at the layout level based on the actual template has defined content_for(:an__area), any idea how to get this done? ...

Unicode issues with acts_as_taggable_on_steroids

I'm implementing a blog with tags with some French characters. My question has to do with how to deal with spaces and unicode (utf-8) characters in the url. let's say I have a tag called: ohlàlà! and I have the following code in my tag cloud: <%= link_to h(tag.name.capitalize), { :controller => :blog, :action => :tag, :id => h(tag.name...

"suggest" feature for textboxes in a rails app

I'm looking for an easiest way how to implement the "suggest" feature for a text entry field in a Rails application. The idea is to complete names stored in a database column, giving the user a drop-down menu of possible matches as he types. Thanks for any suggestions! ...

Building User ID/Password Functionality with Ruby on Rails? Overkill?

Hi, I am new to this community, but I am working on a site that requires implementation of a user/password/register check upon entry, which would check against a database, or write to the database, in the case of registration. I have experience with XHTML and CSS, and just discovered RoR. I honestly have very little insight into how to a...

How to test with RSpec a Rails plugin using "link_to" and "current_page?"

I'm writing a Rails plugin that builds up a menu in a view. I'm using link_to to build the link and *current_page?* to set class="active" on the current page. I've included ActionView::Helpers::UrlHelper so I can use link_to. To get current_page? working in the view, I've had to inherit the current class (apparently ActionView::Base) a...

How do you do relative time in Rails?

I'm writing a Rails application, but can't seem to find how to do relative time, i.e. if given a certain Time class, it can calculate "30 seconds ago" or "2 days ago" or if it's longer than a month "9/1/2008", etc. ...

How do I test Rails block helpers with rSpec

In my views I use a helper that takes arbitrary HTML as a block: <% some_block_helper do %> Some arbitrary HTML and ERB variables here. More HTML here. <% end %> My helper does a bunch of things to the passed block of HTML before rendering it back to the view (Markdown and other formatting). I would like to know what are the clean...

Proxy choices: mod_proxy_balancer, nginx + proxy balancer, haproxy?

We're running a Rails site at http://hansard.millbanksystems.com, on a dedicated Accelerator. We currently have Apache setup with mod-proxy-balancer, proxying to four mongrels running the application. Some requests are rather slow and in order to prevent the situation where other requests get queued up behind them, we're considering opt...