ruby-on-rails

Typus not working in Heroku (error 500) what im doing wrong?

Have someone used Typus (admin plugin for rails) in Heroku? http://intraducibles.com/projects/typus/install I follow the instructions and in my local machine (Rails 2.3.5) is working fine, but when I deploy to Heroku it crashes. What Im doing wrong? the log: Logfile created on Mon Mar 29 18:14:06 -0700 2010 Processing TypusControl...

form_tag for search model

I have a search controller which is to be used to search over a separate model called house. The house model has a restful setup. I want the results listed on the index action of the search controller. The form_tag url is giving me some problems. What is the correct path for this? Below is the search form (search/form): <% ...

What is a good .gitignore to use with Rails on Heroku?

What is a good .gitignore to use with Rails on Heroku? *.log *.sqlite3 what else? ...

How does one NOT html_encode a variable in rails?

With Rails, If I have a variable with HTML content, how do I output it, unencoded in my view file? This code, for example: <% my_variable = "<b>Some Bolded Text</b>" %> <%= my_variable %> Outputs: &lt;b&gt;Some Bolded Text&lt;/b&gt; ...

Ruby on Rails: Model.all.each vs find_by_sql("SELECT * FROM model").each ?

I'm fairly new to RoR. In my controller, I'm iterating over every tuple in the database. For every table, for every column I used to call SomeOtherModel.find_by_sql("SELECT column FROM model").each {|x| #etc } which worked fine enough. When I later changed this to Model.all(:select => "column").each {|x| #etc } the loop starts out a...

Rails performance tests "rake test:benchmark" and "rake test:profile" give me errors

I'm trying to run a blank default performance test with Ruby 1.9 and Rails 2.3.5 and I just can't get it to work! What am I missing here??? rails testapp cd testapp script/generate scaffold User name:string rake db:migrate rake test:benchmark - /usr/local/bin/ruby19 -I"lib:test" "/usr/local/lib/ruby19/gems/1.9.1/gems/rake-0.8.7/lib/...

Rails: Multiple "has_many through" for the two same models?

Can't wrap my head around this... class User < ActiveRecord::Base has_many :fantasies, :through => :fantasizings has_many :fantasizings, :dependent => :destroy end class Fantasy < ActiveRecord::Base has_many :users, :through => :fantasizings has_many :fantasizings, :dependent => :destroy end class Fantasizing < ActiveRecord::B...

Rails STI: SuperClass Model Methods called from SubClass

I would like a little confirmation that I'm doing this correctly. Using rails single table inheritance I have the following models and class method: class PhoneNumber < ActiveRecord::Base def self.qual?(number) klass = self klass.exists?(:phone_number => phone_number) end end class Bubba < PhoneNumber end class Rufus < Pho...

Ruby on Rails Report Generator

Hi There. Is there a way that I can produce a report in RoR without using Ruport or any other report generator rails plugin? Thanks in advance ...

Rails link to current page and passing parameters to it

I am adding I18N to my rails application by passing the locale using url params. My urls are looking like http://example.com/en/users and http://example.com/ar/users (for the english and arabic locales respectively). In my routes file, I have defined my routes with a :path_prefix option: map.resources :users, :path_prefix => '/:locale'...

Why don't RSpec's methods, "get", "post", "put", "delete" work in a controller spec in a gem (or outside Rails)?

I'm not new to Rails or Rspec, but I'm new to making gems. When I test my controllers, the REST methods "get", "post", "put", "delete" give me an undefined method error. Below you'll find code, but if you prefer to see it in a pastie, click here. Thanks! Here's my spec_helper: $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.un...

rails i18n - translating text with links inside.

Hi there! I'd like to i18n a text that looks like this: Already signed up? Log in! Note that there is a link on the text. On this example it points to google - in reality it will point to my app's log_in_path. I've found two ways of doing this, but none of them looks "right". The first way I know involves having this my en.yml: ...

Writing Rails project documentation

Hi to all. Give me an example, that's you can describe as "well documented project on Rails", or "best practices of making documentation for Rails project" (with link to github, or other same site, if it possible). And, what tools do you prefer to use for writing documentation of your project? ...

rails question: how to create multiple child objects linked to a parent object with a select drop down in the parents create form?

Hi there, In a booking engine for buying tickets for events, written in rails, I have the following models: an order a ticket One order has many tickets, and one ticket belongs to an event. People that want to book tickets for an event, typically create a new order. They fill in some details (kept in the order model), and at the end...

How to add a new field in an existing rails application

I have developed a web application with fields Keyword,Latitude and Longitude. I want to add one more field called Radius to the web application.. How should i proceed. Waiting for the reply, Thanks in advance ...

Rails upload to s3 performance issue

Hello, I'm building an app to store files on my s3 account. I use Rails 3.0.0beta A lot of files can be uploaded at the same time, and the cost (from a performance point of view) of an upload is quite heavy, my app will be busy handling uploads all the time! Maybe a solution is to upload directly to s3, but I still need a submit to my...

Git + GitHub + Heroku

Hi All, I am new to the world of Git, GitHub and Heroku. So far, I am enjoying this paradigm but coming from a background with SVN, things seems a bit complicated to me in the world of Git. I am facing a problem for which I am looking for a solution. Scenario: 1. I have setup a new private project on GitHub. I forked the private proje...

RESTful Question/Answer design?

This is a toy project I'm working on at the moment. My app contains questions with multiple choice answers. The question url is in the following format, with GET & POST mapping to different actions on the questions controller. GET: url.com/questions/:category/:difficulty => 'ask' POST: url.com/questions/:category/:difficulty ...

Ruby: UnknownAttributeError

Hi i have some Orders that can have several Items and these Items have an associated Kind. The Kind can belong to many Items. but i get a "unknown attribute: kinds" in my OrdersController when i hit the submit form button. I use nested forms btw. Order.rb class Order < ActiveRecord::Base validates_presence_of :ref_nr, :total_price ...

Rails controller when no ActiveRecord model ?

Hello, I'm trying to create a rails web app that does not use ActiveRecord framework as I have no relational database back end. So far I managed to create a simple example application that works perfectly for listing, showing and editing my records. However I'm facing some problems when it comes to the record creation. The issue is...