ruby-on-rails

Problem requiring gem for acts_as_taggable in rails

I'm trying to get tags working in my rails application and want to use acts_as_taggable. Firstly I followed the instructions I found in Rails Recipies (a free sample bit online) that used the acts_as_taggable plugin. However, I then found this site which seems to have a gem for acts_as_taggable which is more advanced (has options for rel...

Interpret \n within irb or script/console

When using something like object.methods.sort.to_yaml I'd like to have irb interpret the \n characters rather than print them. I currently get the following output: --- \n- "&"\n- "*"\n- +\n- "-"\n- "<<"\n- <=>\n ... What I'd like is something similar to this: --- - "&" - "*" - + - "-" - "<<" - <=> Is this possible? Is the...

CSS not working with IIS7

I have a rails application that I am running with Vista,IIS7 and SQL 2005. For some reason the CSS is not being rendered. The CSS works fine when I use Webrick. Any ideas how to get CSS working correctly with IIS7. I have uninstalled and reinstalled windows components "Common Http Features" with no luck. ...

Why do I need to work harder to make my Rails application fit into a RESTful architecture?

The Background I started a Rails project recently and decided to use RESTful controllers. I created controllers for my key entities (such as Country) and added index, new, edit, create, show, update, delete. I added my map.resources :country to my routes file and life was good. After development progressed a little, I started to encoun...

Mongrel::DirHandler equivalent for Passenger

I'm using Mongrel::DirHandler to control response headers for static files - this works great on my dev machine. My production machine uses Passenger so my headers aren't getting set. How do I control headers for static files when using Passenger? snippet from my environment.rb: if defined? Mongrel::DirHandler module Mongrel clas...

Multiple rail apps using Apache and Mongrel

I am actually developing and application that has around 15 modules, all of them using the same database. I am using Apache + Mongrel, I cannot use Passenger because I am working on Windows (please forgive me for this deadly sin!) Which of the following is a better approach? Deploy multiple small rails applications using a virtual se...

Can I have url_for use a prefix option in Ruby on Rails?

In a project I am working on, Apache is set up to only forward requests that come in as /prefix/* to mongrel. How can I tell ruby on rails to generate all URLs with that prefix? I have the routes set up for forward to the correct controller action by doing this: map.connect 'sfc/:controller/:action' but that doesn't seem to affect t...

Installing a rails plugin from a Git repository

I've been trying to install Shoulda script/plugin install git://github.com/thoughtbot/shoulda.git but all I get is: removing: C:/Documents and Settings/Danny/My Documents/Projects/Ruby On Rails/_ProjectName_/vendor/plugins/shoulda/.git > And the vender/plugins directory is empty. I have Rails 2.1.1 installed as a gem and have verif...

RedCloth's odd support of the <del> tag

I am using RedCloth with Rails 2.1.1. The Textile <del> tag markup format (i.e. -delete-) was not translating at all. Tried a few choice options. > x=RedCloth.new('foobar -blah-') => "foobar -blah-" > x.to_html => "<p>foobar <del>blah</del></p>" # WORKED! > x=RedCloth.new('foobar * -blah-') => "foobar * -blah-" > x.to_html => "<p>foob...

Getting renders to recognize custom routing paths

So I have a snazzy custom route for login # routes.rb map.login '/login', :controller => 'sessions', :action => 'new' Visit www.asite.com/login and you're there. As is custom with failed login, however, we'll do the following in our action. Note what happens on failed login. # sessions_controller.rb def create self.current_us...

Rails: Detecting user agent works in development but not production?

I am trying to detect Blackberry user agents in my app, which works fine in my development version. But nothing happens when I redeploy the app in production. application_helper.rb def blackberry_user_agent? request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Blackberry)/] end application.html.erb <% if blackb...

Why is rake throwing this Rails migration error?

I have two machines... a development machine and a production machine. When I first brought my rails app onto the production server, I had no problem. I simply imported schema.rb by running rake db:schema:load RAILS_ENV=production. All was well. So, then on my development machine, I made some more changes and another migration, and t...

AJAX, Rails, and dynamic loading of forms.

I have a rails app that has picked up a bit of traction, but I have a serious headache to deal with. It's a basic sort of asset manager application - users upload their photos, .pdfs, videos, etc., and the system allows them to manage how that asset is presented. I started with a fairly standard rails view - just what gets generated by...

"Cannot add array to BooleanQuery" error with ferret on rails

I'm trying to get a simple search form working in my RoR site. I've got the following code: (in note_controller.rb) def search @results = Note.find_with_ferret(params[:term]).sort_by(&:ferret_rank) respond_to do |format| format.html format.xml { render :xml => @nootes } end end (in note.rb) class Note < ...

Good rails generator tutorial?

As title, good I mean with detail coverage of m.template, m.class_collisions etc. A paid book or free online resources would be acceptable too. ...

How can I submit a form in RoR whenever an input textfield changes?

I am using Ruby on Rails. I want to create a filter field on a page such that whenever the input field's value changes I filter a list shown below via ajax. (Exaclty like the Users search works in Stackoverflow) For now, I made it run with a form_remote_tag containing a text_field_tag and a submit_tag, and it filters my list when I pus...

How do I get a zipped file's content using the rubyzip library?

I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation. There is an assets table that has key :string (file name) and data :binary (file contents). I'm using the rubyzip library, and have made it as far as this: Zip::ZipFile.open(@f...

How to validate Markdown?

It's possible to write Markdown content with invalid syntax. Invalid means that the BlueCloth library fails to parse the content and throws an exception. The markdown helper in Rails doesn't catch any BlueCloth exceptions and because of that the complete page fails to render (500 Server Error page is rendered instead). In my case, users...

Simplest way to send mail with Ruby on Rails

What is the simplest way to send mail using Ruby on Rails? Is there a way to send mail directly via ruby and skip all the rails models and complexity, just like php's mail() function? Thanks for your help. ...

How to interpret the memory usage figures?

Can someone explain this in a practical way? Sample represents usage for one, low-traffic Rails site using Nginx and 3 Mongrel clusters. I ask because I am aiming to learn about page caching, wondering if these figures have significant meaning to that process. Thank you. Great site! me@vps:~$ free -m total u...