ruby-on-rails

Display search query in results of basic search in Rails

I built a basic search form that queries one column in one table of my app. I followed episode 37 Railscast: http://railscasts.com/episodes/37-simple-search-form Here's my problem. I want to display the search query that the user makes in the view that displays the search results. In my app, the search queries the zip code column of ...

Trouble installing Rails App on MediaTemple?

I am having some trouble installing an app on MediaTemple's Grid Servers... I'm deploying with cap and github... everything seems to go ok with those, but the app won't start up. There seems to be a problem with my database.yml file? I've checked for space errors and those all look good. Here is a copy of the console when I try and st...

How to require a value is entered in a search form

I built a basic search form that queries one column in one table of my app. I followed episode 37 Railscast: http://railscasts.com/episodes/37-simple-search-form. Note I just posted another search related question, but it's on a completely different issue. In my app, the search queries the zip code column of my profile table, and retur...

Django-like framework on Ruby?

Django as a framework is a neat little package. There are very few files (compared to Rails) and it's got a clean structure. The fact that you can plug and unplug apps between different projects is an extremely nifty feature. At the same time, Ruby's hacking ability is unparalleled. It's complete object-orientedness makes it more express...

The last 20% in Ruby on Rails

I am (quite) an experienced programmer but totally new to Ruby and Ruby on Rails. RoR looks great to get working quickly, specially the automatic screen generation for CRUD operations. It really it gets you productive quickly. The questions is with the last 20% of the work, when I must finish my application. Won't RoR conventions stan...

Is it possible to render a different exception page if the request is an XmlHttpRequest?

If there's an exception in a Rails application, one gets an error page with the call stack, request parameters and a code excerpt. Is it possible to create a different output if the request is an XHR request? Is it possible to re-define the exception output in general? (I assume that would automatically answer the first question) ...

Rails: Custom ordering of records

Does ruby or rails provide a method to order strings in a specified order? Say that I have the following priorities "Severe, High, Medium, Low". These priorities are not going to change frequently (if at all). I have a Task model with a priority column: tasks - id (integer) - name (string) - priority (string) I'd like to get ...

Rails template and run command

Hi! I've got a problem when I used a new templates functionality in Rails 2.3 (updated InstantRails on Windows Vista). I created a template and called it test.rb. test.rb run "gem sources -a http://gems.github.com" I tried to execute rails tt -m test.rb and got: create log/development.log create log/test.log applying template:...

Rails Authlogic and GeoRuby conflict?

I have a problem with GeoRuby conflicting with Authlogic. I set up a very simple application that only lets me register and log in and out useing Authlogic. This works fine. Then I added GeoRuby to the application and I get the error: wrong number of arguments (1 for 2) when the current_user is called in the view. I'm quite new to...

Update array in rails action?

Hey guys, I have the following code in an action: @user = @current_user @user.votes[1430]='up' @user.update_attributes(params[:user]) Votes is a string type, there is no default value - I just want to set it for the first time when this action occurs. Unfortunately I get this error: NoMethodError You have a nil object when you didn...

Proper RESTful routing for rails application?

Hello, this is my first post on this website, but I'm all the time getting answers for my questions here, through other users, so thank you very much. Well, actually I'm creating a web application, specifically on rails. All the models structure were built and now I was pretending to start to build the controllers and routing. So, I hav...

Planning for 2 Types of Users on a Rails App

What is the best way to architect a Rails app to handle two distinct classes of users? For a marketplace there'll be Buyers and Sellers. There will be overlapping functionality in editing the profiles and such, but most the funcitonality will be distinct. Is the approach in the following post a good way to do it? I'm hoping to use RE...

Rails logging best practices

Often I find myself inserting logging statements like this into my code: logger.info("orphaned_annotations: ".upcase + orphaned_annotations.to_s) logger.info("orphaned_anchors: ".upcase + orphaned_anchors.to_s) It seems like this would be a pretty common use-case -- is there an easier way to get this kind of functionality? ...

How do I properly include a module and call module functions from my Rails model?

I have a model, Show and a module Utilities class Show < ActiveRecord::Base include Utilities ... def self.something fix_url("www.google.com") end end My Utilities file is in lib/utilities.rb module Utilities def fix_url(u) !!( u !~ /\A(?:http:\/\/|https:\/\/)/i ) ? "http://#{u}" : u end end But Rails is t...

Why do Ruby developers appear not to use UML?

I always hear about UML being used in Java projects but never in Ruby ones. Is this just a cultural difference or is there less of a need for modeling in Ruby development because it's part of a more 'agile' culture? ...

Newbie Seeking to Learn RoR - Good Online Tutorials?

Hi, Stackoverflow folks. I want to teach myself RoR. I am a newbie to Web development. I hate reading manuals and learn best by doing, rather than reading. I understand the basics of RoR conventions and the idea behind it. But for me the best way to learn how to use stuff is to have a step-by-step guide walk me through stuff like setup, ...

Multiple one-to-many associations in one model

Given two model classes, Foo and Bar, I want Foo to have 3 references to separate instances of Bar using 3 different property names, with the foreign key on the Foo table. Bar will be managed separately and can belong to many instances of Foo. This somewhat explains it, obviously has_one is the wrong association to use (I think?): Foo ...

Rails resource_controller with interruption?

I want to use the before action to optionally interrupt the processing if it fails to comply certain criteria (e.g. the object is not owned by such user etc) I need to use this because I have a more complicated scenario that I need the object to be loaded before the access rights could be determined, so I would have situations where I w...

How can i display an error for ajax in rails.

I am trying to display an error message of flash in Ajax using Rails but it doesn't display it, and I have tried several ways to do it but I just can't get it right. Here is my form to display my errors: #flash-error.flash-error{:style => "display: none"} #flash-notice.flash-info{:style => "display: none"} %h3 New Document - f...

Rails Rake: How to pass in arguments to a task with :environment

So I am able to pass in arguments as follows desc "Testing args" task: :hello, :user, :message do |t, args| args.with_defaults(:message => "Thanks for logging on") puts "Hello #{args[:user]}. #{:message}" end I am also able to load the current environment for a Rails application desc "Testing environment" task: :hello => :environ...