ruby-on-rails3

Filtering child objects in a has_many :through relationship in Rails 3

Greetings, I have an application where Companies and Users need to belong to each other through a CompanyMembership model, which contains extra information about the membership (specifically, whether or not the User is an admin of the company, via a boolean value admin). A simple version of the code: class CompanyMembership < ActiveRec...

Code once, deploy in multiple devices

Hi, How can I code once and deploy on Windows, Mac, Web and Mobile? App Titanium does not deploy on the Web. Thanks ...

Rails 3: Custom error message in validation

I don't understand why the following is not working in Rails 3. I'm getting "undefined local variable or method `custom_message'" error. validates :to_email, :email_format => { :message => custom_message } def custom_message self.to_name + "'s email is not valid" end I also tried using :message => :custom_message instead as was sug...

Bubbling of Rails3 validation? Custom validate vs. validates_presence_of

I have two validations.. validates_presence_of :name validate :category? In my category? validation, it asks for a Model.category.downcase method. I made a spec where no category exists, and it is failing in my specs because no category exists for it to downcase. My question is, how do I set up my model to first validate if the name ...

Rails3 Routing error. No route matches {:action=>"destroy"

I'm following the guide at, http://guides.rubyonrails.org/getting_started.html Ruby 1.9.2p0 Rails 3.0.0 But I'm locked at 6.2/6.3, when I try to add the; <%= link_to "Species", species_path %> I get the error (I switched the Post example to Specie); ActionController::RoutingError in Home#index No route matches {:act...

undefined method `each' in a factory_girl / rspec2 scenario

I'm trying to Factory a Post associated with a Vote. So that Post.votes would generate the Vote's that are associated with it. Factory.define :voted_post, :parent => :post, :class => Post do |p| p.association :votes, :factory => :vote end And my rspec2 is relatively straightforward : describe "vote scores" do it "should show me t...

Ruby On Rails 3 submit_tag Options Question

In a form tag, besides submit_tag and image_submit_tag what other input types can I use. I have something like this but what I"m trying to do is make a button that will submit the form using the css class button big grey. <%= submit_tag "Join", :class=>"button big grey" %> Thank you in advance. ...

Rails 3's link_to('&raquo;', url) won't work if it is &raquo; or other entities

because it will not show up as » but will show up as &raquo. Is there a way to show it? ...

AJAX autocomplete with jQuery in a Ruby on Rails 3 application

I would like to implement an AJAX "autocomplete search" feature of my Ruby on Rails 3 application. I would like to use jQuery to implement the JavaScript portion. Is there a popular approach (or tutorial) to implement this? ...

Best way to handle this RESTfully

I have a Scouts model that requires two actions in addition to the standard REST actions, check_in and check_out. So I have my route as: resources :scouts do member do get 'check_in' get 'check_out' end end But I need to display the show.html to the user, with a link to check_in the Scout or check_out the scout. In order ...

Ruby on rails "No route matches"

Hi all, I am new to Rails and am just implementing some basic applications. Just starting on my second app and have run into what is a basic problem, but Google is yielding me nothing. Getting this error: No route matches {:controller=>"user", :action=>"admin_login"} Here is my routes.rb Blah::Application.routes.draw do r...

Rails Acts As Commentable, Support for multiple Models? AJAX?

Hello, I'm interested in adding commenting to my Rails 3 app. Acts As Commentable seems to be best choice out there even though it's a little dated? I'd like your input on Can Acts as Commentable support multiple models? Example, I want commenting on items Like Books, Authors, Chapters, etc.. which are all separate pages. Is this poss...

Moving from MySQL to to Postgres on Rails 3

Aside from removal of some MySQL specific queries, the migration was pretty smooth. The problem now is, that during developement there is a lot more queries to the DB than before. Started GET "/profiles/data" for 127.0.0.1 at Tue Sep 21 10:26:18 +0200 2010 Processing by ProfilesController#data as JSON User Load (24.3ms) SELECT "users...

How reliable is Heroku for a sensitive app?

Hi, How reliable is Heroku for a sensitive app? Can they be trusted for a very important app? Have you used it for a long time? What's your opinion? Thanks ...

Apply javascript to form

Hi, I would like to use this piece of code http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.asp but I don't know how to apply it to my form. I'm using Rails 3 and the form is called user_edit. ...

To gem or not, that is the question

Hello! I'm building a simple CMS on Rails and I'm thinking about how I can package it so that I can easily reuse it in other projects and eventually share it as open source. This leaves me wondering if it's possible to package it as a gem, with views, controllers, models, images, stylesheets, etc, and later just include it in a new sit...

Rails 3 acts_as_commentable Error: undefined local variable or method `acts_as_commentable'

Hello, I'm building a Rails 3 app and am trying to install acts_as_commentable Here's what I did: Added to my Gemfile: gem "acts_as_commentable" Ran bundle install Generated a Migration with the comments.rb (Comments table was created correctly) I then wanted to enable my book controller for commenting, so I added to books_controll...

remote action when clicking radio button in rails3

I'm upgrading a rails2 application that has some inline javascript to rails3 that I'm having trouble converting to UJS. Specifically, I can't figure out how to call change_values.js.rjs when clicking on a radio button. My rails2 code looks like this: <%= form_tag do %> <%= radio_button_tag "shared_name", "1st_button", true, :o...

How do I use connect to Gmail's IMAP server using oauth in Rails3?

I found the gmail_xoauth gem, which does most of what I need, but I also need to generate the oauth tokens (consumer_key and consumer_secret) from inside Rails3. I am trying to integrate Gmail's oauth integration into my site and hence cannot use the python script that the above gem refers to. I would like my site to take the user to th...

Using Rails Form Helpers with Serialized Custom Classes

Hey, I'm trying to save a hash of options in a single DB field. The form is able to save the data to the DB but not able to retrieve it again when I go to edit it (e.g. all the other fields are prepopulated except for the wp_options fields). class Profile < ActiveRecord::Base serialize :wp_options end This is my custom class: ...