ruby-on-rails

In rails, How to send emails with action mailer using mdaemon mail server?

I have installed mdaemon mail server in my computer, and register the email user "[email protected]". I have also tested it with "worldclient" that it can send emails correctly. Now I want to send emails with action mailer using this mail server. But I cannot send email correctly. The sending email method is shown below: def re...

How to install Rails 2.3.2 and 2.3.4 simultaneously on Ubuntu 9.04?

I need to install Rails 2.3.2 and Rails 2.3.4 simultaneously on my Ubuntu 9.04 server. How do I do this? When I run: sudo gem install rails ...it installs version 2.3.4. Is there a single command I can use to also install 2.3.2 parallel to the default (latest) version? Thanks! ...

Formtastic select list

<% semantic_form_for(@product, :html => {:multipart => true}) do |f| %> <% f.inputs do %> <%= f.input :name %> <%= f.input :price %> <%= f.input :pno %> <%= f.input :description %> <%= f.input :shop_category %> <% end %> <% end %> Product belongs to Shop_category, Shop_category belongs t...

Supplying default options for error_messages_for

I have a website with several forms that all pass the same set of arguments to error_messages_for. Is there a way for me to configure rails to use my default arguments other than creating a helper method which wraps error_messages_for with my arguments? ...

Stubbing named_scope in an RSpec Controller

I haven't been able to find anything for a situation like this. I have a model which has a named scope defined thusly: class Customer < ActiveRecord::Base # ... named_scope :active_customers, :conditions => { :active => true } end and I'm trying to stub it out in my Controller spec: # spec/customers_controller_spec.rb describe C...

Symlinking problem

Hey dudes.i am having this problem while symlinking. I have successfully deployed a ruby on rails application on server and all the migrations are done. It is deployed with phusion passenger. The application is in /home/username/rails_apps/myapp. I want to symlink it to a subdomain in my site. the path to subdomain is /home/username/publ...

Sending USR2 to mongrel_rails sometimes results in an "Address already in use" on the restart

We have a rolling-restart mode for our mongrel cluster that sends a USR2 signal to each running process. This works great, most of the time. But very occasionally the mongrel process will shutdown, and then fail to restart, with the following error: /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/tcphack.rb:12:in `...

efficiently storing "answers"

I'm building out an Answer ActiveRecord class that can have different types of answers. That is, the answer could be an integer, float, date, string... whatever... The way I see it there are two ways to store the answers 1) Have an attribute named "value" that is serialized. This is nice since you can always access the answer from ...

Netbeans Source Format: Can It Recognize Other Stuff? (For RoR Views)

I am in love with Netbeans Source->Format feature. Is there any way to get it to recognize stuff in these blocks <% content_for :style do %> <% end %> as CSS? It would also help for autocomplete. Ditto, of course, for <% content_for :javascript do %> <% end %> blocks. ...

Command to use inside the controller's action logic to determine the route that caused that action to be invoked?

I used rake routes to print out all of the routes in my application. What I found is that a couple of routes map to the same controller/action combination. So in my action I would like to display which route was actually used to track down where everthing is coming from. I tried just rendering params.inspect as text: render :text => ...

How to handle many forms on one page?

If I have a single page with many forms of existing records: index.html.haml - for selection in @selections - form_for selection, :method => :put do |form| = form.collection_select :user_id, @current_account.users, :id, :full_name and then this for submits to and update action: selections_controller.rb def update selection ...

How to improve performance with our Rails image model and attachment_fu?

I've been trying to improve performance our app. The worst performing area seems to be the creation of our Image model, which uses attachment_fu: class Image < Attachment ... has_attachment :content_type => :image, :max_size => 100.megabytes, :storage => :file_system, :path_prefix => 'public/uploaded/images', :thum...

Outputting (puts, print) in Rails Unit Tests

How come commands like puts and print don't show up in the console when running ActiveSupport::TestCase tests? Makes it very hard to debug if I can't outputs some inspections in a couple of methods. Thanks! ...

Using rails named routes within custom rendered ERB templates

I have a method on an active record class that renders an ERB template for a messaging system. The simplified code looks like this: ERB.new(template).result(binding) where binding is the current Binding of the ActiveRecord model object and template is an erb template file read in from the file system. I would like to use some named...

Rails Multiple Table Inheritance question

I am starting to implement an MTI solution and have a basic question. I have 3 physical models - SMSNotifications, EmailNotifications, TwitterNotifications and they are subclasses of notification. At times in my code, I want to say Notifications.find(:all)so that I can get a set of results sorted by their creation time. Then I want to ...

ruby on rails pluralization help?

My app is gonna be in spanish. Say I want to scaffold generate actividad. the plural would be actividades so I want the table and the controller to be named that .... how can I do this? ...

Rails ActiveRecord Problem With Complex Join - Select Does Not Work

Hello, I have two model objects: Event Venue Events have Venues. Venues can have 1..* events. Venues have a location, a lat and long, which I use with the Geokit Rails plugin. Here's what these models look like in Rails: class Event < ActiveRecord::Base belongs_to :venue acts_as_mappable :through => :venue end and class Ven...

SQLite3 helper?

Is there any application like SQL Buddy for SQLite3 for Mac. I am just starting with Ruby on Rails and have my environment set up on my Mac running Snow Leopard, I have used SQL Buddy before and I was wondering if anyone knows anything like that for SQLite3. ...

Terminal Command Mac Alter table SQLite3...

What is the terminal command, or where is a good resource to get them, to alter a table. And, do I need to re run the $rake db:migrate after I do this? I am running RoR on Snow Leopard. Last question, can I make an already created column non-null. UPDATE: figured out how to alter, just need to know if I need to rake db:migrate after a...

Problem communicating with Gmail in Rails app

I'm getting an error while trying to use the action_mailer_tls plugin to communicate with Gmail in my Rails app: Must issue a STARTTLS command first Others seem to have encountered this same problem: The problem is that Gmail requires TLS authentication but the standard Ruby net/smtp library doesn't support TLS. The article ...