ruby-on-rails3

Ruby Upgrade for Rails 3 Install

I seem to have gotten myself turned around while trying to install Rails 3 and haven't been able to figure out what I'm doing wrong. Prior to trying to upgrade I was on 2.3.2 Here's what I have thus far... $ which ruby /usr/local/bin/ruby $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0] $ which rails /usr/bin/rail...

simulate heroku on local (nginx + rails 3 app)

Hi, I am trying to simulate heroku on my local since our app is on heroku. I don't have access to the app in heroku though, so I just plan in recreating the same environment heroku has in implementing SSL for our app. Anyway, I searched heroku and based on my findings and assumptions, they are using nginx. I am using WEBrick right now a...

problem with ketchup jquery plugin

I am using jquery ketchup form my forms and i am having problems with the positioning of the error messages. The forms have different styles, so one is more of a label input structure. while another one is on a label input structure. this totally messes up my ketchup plugin since it is assuming im using the same styles on both ...

Modifying devise modules after first generation

Hi, I'm in the process of learning rails. I've found Devise to be great with getting authentication up and running quickly and seamlessly but I do have one question. How do I change the modules after the first run of the Devise generator (e.g. rails g devise User)? This defaults with the following migration: def self.up create_tab...

Defining :id in routes to be something other than id in rails 3

I am porting a Merb app to Rails 3. In Merb we could put an Identify block around a route to define how an :id route parameter was to be supplied, e.g., # this is a Merb route that I want to port to Rails 3 routing; I get everything except # how to replicate the behavior of Merb's Identify block which doesn't require one to # futz wit...

NULL in (NULL) does not match properly...

Using Rails 3 active relation, I have a scope: scope :duplicate_contact, lambda {|contact| where( :person_id => contact.person_id, :salutation => contact.salutation, :first_name => contact.first_name, :last_name => contact.last_na...

hyphen in rails 3 route

I would like to do the following match "company/client-list" => 'companies#list' however, when I do, my routes table entry doesn't name the route, like so. /company/client-list(.:format) {:controller=>"companies", :action=>"list"} as soon as I remove the hyphen in the matched route, it behaves as expected company_cl...

Rails3 problem with editing a nested models

Greetings, I have three models class Patient < ActiveRecord::Base has_many :admissions accepts_nested_attributes_for :admissions, :reject_if => :all_blank, :allow_destroy => true end class Admission < ActiveRecord::Base belongs_to :patient has_one :admission_info, :dependent => :destroy accepts_nested_attributes_for :admiss...

RoR 3 - overriding the FormBuilder default f.submit into a button

I have a form, and for layout (and future use), i would like to know how to change the default f.submit that generates a: To a html tag that shouldn't give any errors. What i have now is an extention on the formbuilder In my view: <%= form_for resource, :as => resource_name, :url => session_path(resource_name), :class => "for...

rails3 I18n: can't override "1 error prohibited this packet from being saved:"

When i get errors on model Packet, i always see the first (english=not translated) line: 1 error prohibited this packet from being saved: Naam Gelieve het veld Naam in te vullen! The translations for the error for the single field is found! While i have the following in my nl.yml nl: activemodel: errors: template: ...

RoR 3 - f.label embeds an <span> tag - howto

How would i do the following. My current code is : <%= f.label :email, html_escape("<span class=\"big\">Test</span>") %> This doesn't shows what i want, because the <span class=\"big\">Test</span> is shown as text instead of HTML. I have been thinking of overriding the FormBuilder, but i don't know how i would do this and sea...

Rails 3 Observer -- looking to learn how to implement an Observer for multiple models.

Hello, I'd like to add an Auditor Observer which does an action anytime after_create for 3 models (books, characters, authors)... I recently heard of the Observer capability but can't find any documentation on the ability. Is it support in Rails 3? How do I create an Auditor Observer that does something after_create for 3 models? Than...

Rails 3 - Looping through DB records, one record has a HASH

Given a database with records like the following Table: AuditLog Fields: ID | USERID | TYPE | TIME | DATA id:1, userId:1, type:PHOTO, time:2008-10-15 12:00:00, data:{photoId:2089, photoName:A trip to the beach} Lets say the database had 50 records, with Rails How can I loop through the results as follows: id, user_id, data.photoI...

how to use haml in rails3?

I want to use haml in rails 3 project. Now how to start? How to cofig it? ...

Ruby on Rails 3 Select Helper Question

Have have this line of code in my form when I create a new item. Though when I edit the item, the default selection isn't the one that is selected. Do I need to set the initial value? <%= f.select :category, options_for_select(Item::CATEGORIES) %> ...

Rails 3 Case Statement in a View

Hello... I have an AuditLog with things like id | action | type | description... What I'd like to do in the View is something like Case description when "created" created styling when "deleted" deleted styling else error end Trying to learn how to do this in a view and the correct syntax, which the resources I found ...

delete child when parent is deleted is not working.

Well the situation is bit more complicated than that ! I have a question model class Question < ActiveRecord::Base has_many :answers, :dependent => :destroy then an answer Model class Answer < ActiveRecord::Base belongs_to :question, :counter_cache => true has_many :rep_events, :class_name => "RepEvent", :foreign_key => "event...

Raisl 3 - howto ... Storing Unstructured Data in a database column field Data

Hello, I'd like to learn the smart way to store unstructured data in a DATA field so for example, if I have the Table AuditLog with the fields id | model_name | data And in Data I want to store various types of data which changes based on the model_name. I also want it in data so I can output these records w/o using JOINs for performan...

Rails 3 - What's wrong with this CASE Statement?

<% @feed.each do |feed| %> <ul id="feed"> <%= case feed.action_type when "COMMENT" <%= render :partial => "feeds/storyitem" -%>, end %> </ul> <% end %> ...

[rails3] comments not saving post_id

Im running into a small (newbie) problem. I've got 2 models: question & reviews. Reviews schema: question_id, user_id, rating, comments On the 'show' view, i've integrated the following form (formtastic): - semantic_form_for @question.reviews.build do |f| = f.error_messages = f.input :rating = f.input :comments = f...