ruby-on-rails

rake jobs:work error, uninitialized constant ...

i am using delayed_job 2.1.0.pre2, and in my lib i have a class which named MailingJob(mailing_job.rb),and it has one method named perform. In my controller , i put a new MailingJob object in my delayed_job queue as the doc said. but when i run the "rake jobs:work" command,it always told me that it can't find "MailingJob", is it necessar...

Do all join tables have tables?

For example I have a comments models, and I have a post model, but comments can comment on other comments. So it seems I need a join table I'll call commentables. To create this, do I really need to create a commentable table with a post_id and a comment_id ? Or can I do something like this without one : has_many :comments...

Rails, seed database from other database?

How can I seed my database from the records in a different database? For example, I have an existing database that has many records that I want to import into my application, I'm really just a bit lost on how people typically do something like this in a pragmatic "Rails" way. Thoughts? ...

rails 3 has_many :through record save error

I'm not exactly sure what my problem is, so this question may require some more clarification, but here's what seems to be most relevant: I have a has_many :through and the join model has some fields that aren't foreign keys. When I build the models up and try to save I get a validation error on the non-foreign key fields from the join...

reaching Gmail SMTP daily limit

Hello guys, In one of my Rails applications I'm sending emails through the Gmail SMTP server and everything just works, mails are not going to spam and so on ... But there's one thing that concerns me, the 500messages/day limit the SMTP has, currently I'm over 350/day. I didn't find any official Google page where they talk about the subj...

Error handling in rails

Oddly I'm having a hard time finding good docs about basic error handling in rails. I'd appreciate any good links as well as thoughts on a handling errors in a really basic method like this: def self.get_record(id) People.first( :conditions => ["id = ?", id] ) end 1) I could verify that id != nil, and that it's numeric. 2) I ...

Rails 3 has_one/has_many question

I am writing an application that contains a database with several tables and joining tables and so forth... the two I am working with currently (and am stumped on) are my pages table and my templates table. Now a page can contain only one template, but a template can have many pages. Model for Page: class Page < ActiveRecord::Base h...

Rails Select options not working

After going through the process of updating rails to 2.3.8 my select option stopped working in my view. For some reason it now tells me, even when it has something selected that it can't be empty. I have found this to be quite annoying and decided after hours of fighting with it to enlist some help. Here's what I have so far. new.html.e...

Load order with javascript_include_tag :all

So I've recently started to include quite a few .js files in to my web application and some of them depend on each other so load order is important. However rails caching just seems to load a all.js file with no particular order to the files. What's a good way to solve this issue? ...

How to make a Rails view .erb file print the last part of an URL?

I'm brand-spanking new to Rails. I've learned how to make static controller actions and corresponding view files. Now I want to make it so that when I go to localhost:3000/hi/anita, the page says "Hi anita", but when I go to localhost:3000/hi/bob, it says "Hi bob". Of course, I don't want to make anita and bob actions. You get the idea. ...

Rails Model: Name -- First, Last

I'm fairly new to rails, working on a Rails 3 app with a Profile model for users. In the profile Model I'd like to have a "name" entry, and I'd like to be able to access logical variations of it using simple syntax like: user.profile.name = "John Doe" user.profile.name.first = "John" user.profile.name.last = "Doe" Is this possible, o...

RESTful nested conventional routing

Hi, I have the model: User -1---n- Transaction(amount,description, date) User -1---n- TransactionImport -1---n- TransactonImportField(name,value) (personal expense tracking app). What I want to achieve is this: User opens URL and pastes the CSV with the list of transactions. User submits it. System extracts data from CSV into Tra...

Rails custom actions

I am not sure if I am going about this the right way or not. I have a model Neighborhood. I have a two ways you can add a neighborhood, one as a logged in user and the other as a public person. The forms vary a bit. So I made another view with a custom action. The problem is this action is adding a new record and therefore calls on "cr...

Rails: specific rake task dependencies for different environments

Hi My main rakefile has some tasks to stop and start selenuim as follows: require 'selenium/rake/tasks' Selenium::Rake::RemoteControlStartTask.new do |rc| rc.port = 4444 rc.timeout_in_seconds = 3 * 60 rc.background = false rc.wait_until_up_and_running = true rc.additional_args << "-singleWindow" end Selenium::Rake::RemoteC...

Controller action is called twice

I've noticed, that "index" action of my controller is called twice. The action has following structure: def index if params[:tags].nil? # [fork #1] just return the whole collection of model @items = Item.all else # [fork #2] filter items by tags @items = Item.select_by_tags params[:tags] end # Another oper...

Paperclip with valums's file-uploader

I am using Paperclip to upload image on Rails3. Now I want to use valums's file-uploader to do multiple image upload. I have already set the multiple image upload correctly. Each Product(a particular model) has_many photos. each photo has_one item. (FROM: rails g paperclip photo item) My question is how to use valums's file-uploader? And...

Datepicker Prototype not working

Hi All, I have installed http://code.google.com/p/calendardateselect/ Datepicker using gem install calendar_date_select Installation was success. but beeing a newbey, i dont know how to use it. i gave in my view file, <%= calendar_date_select_tag "e_date" %> But it throws the error undefined method `calendar_date_select_tag' for #<#:...

Do I really need to setup a mongrel cluster to handle this ?

So my father runs a rather small business. I'm going to set him up with a website using RefineryCMS (that's a ror-based cms).. He will probably get less than 500 hits a month. Do I really need to set up mongrel cluster for this as about every tutorial on the web suggests? Does anyone some good reading material for setting up a simple, ...

Having trouble setting up Apache for SSL with mongrel and rails 3 in development on ubuntu.

I'm trying to setup apache2 so that I can try ssl in development on my rails 3 app on ubuntu. The rails app works, except for https where in Fire Fox i get: The connection was interrupted The connection to localhost:3000 was interrupted while the page was loading. In the console i get: Thu Oct 14 15:56:28 +1100 2010: HTTP parse err...

Intergration tests for fullCalendar

Hello, I love fullCalendar. Its an awesome plugin. However one thing that I have found hard is testing. I am using rails, cucumber, capybera and selenium. I spent a good part of yesterday using the selenium IDE and could not for the life of me get selenium to simulate a click on fullcalendar's interface. I was wondering if anyone else h...