I have a need to use two different smtp servers in a Rails application. It appears that the way ActionMailer is constructed, it is not possible to have different smtp_settings for
a subclass. I could reload the smtp settings for each mailer class whenever a message is being sent, but that messes up the ExceptionNotifier plugin which is ...
Hi,
I have a date string: "2009-10-12". I would like to write a method that takes this as a parameter and returns the three lettered day of the week (in this case 'mon'). I wrote this:
def date_to_day_of_week(date)
d = Date.parse(date).strftime("%a").downcase!
return d
end
When I call this from script/console, it works as expecte...
There is a development_structure.sql inside my /db folder of my rails application (rails 2.3.4, ruby 1.8.7) and I am not sure exactly what it does.
Is it needed for some specific environment? (I think I read somewhere that it's used for tests)
Do I need to add it to my git repository?
...
I am trying to run ActiveMerchant gem with old version of Rails (1.2.6). And if I require active_merchant gem i get this error:
config/boot.rb:17:Warning: Gem::SourceIndex#search support for String patterns is deprecated, use #find_name
/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:280:in `activate': can't activate activesupport (>= 2....
I often find myself writing this:
params.delete(:controller)
params.delete(:action)
params.delete(:other_key)
redirect_to my_path(params)
The trail of deletes doesn't feel right and neither does:
[:controller, :action, :other_key].each do |k|
params.delete(k)
end
Is there anything simpler and cleaner?
...
I'm trying to write a small Rails app that will interface with Jira using the Jira4R gem. However, whilst I'm having no problem creating an issue, I'm having real trouble attaching a custom field to an issue.
Any ideas on how I would do this?
At the moment I'm creating the issue like:
issue = Jira4R::V2::RemoteIssue.new
issue.project...
I'm trying to implement a simple Inbox system for users of my app so that can send basic messages to each other - just like in many forum systems.
If User has_many :messages, how do I keep track of and notify the User of messages unread since last time they were read?
I'm thinking clicks on the link to the Messages screen need to be re...
Hey everyone,
First off apologies for asking one of those A vs B questions that often plague internet forums but I'm in a bit of a dilemma as to what to study next. I've only been a developer professionally for 2 years (almost) and i'm trying to lay the foundation for perhaps doing some freelance work in the future.
Im currently stud...
I've been using the Authlogic rails plugin. Really all I am using it for is to have one admin user who can edit the site. It's not a site where people sign up accounts. I'm going to end up making the create user method restricted by an already logged in user, but of course, when I clear the DB I can't create a user, so I have to prepopul...
I'm testing my app out on Heroku (which is f***ing amazing!) and I realized that I have no way of creating my root user.
I'm using Authlogic and rails_authorization_plugin.
Is there someway I can add a section to one of my migration files to add this user and assign it the role of root? Or can I do this through a rake task?
Any insigh...
At present, my development process flows like this:
I describe the expected behaviour as an integration test using using WebRat
I write the Ruby on Rails code to provide that behaviour, so passing the test
I refactor, ensuring the tests still pass at the end of the process
I write the next integration test
It seems to me that by defi...
I am running into a problem with to_json not rendering my virtual attributes
class Location < ActiveRecord::Base
belongs_to :event
before_create :generate_oid
validates_associated :event
attr_accessor :event_oid
def event_oid
@event_oid = event.oid
end
end
event_oid is not part of the array returned by:...
With the many testing framework that is available in the Ruby community namely: unittest, rspec, shoulda, and coulda, what would be the most appropriate testing framework to test my Rails model?
Do they basically have the same functionality, which is to unittest my model? When should I use which? What is the advantage of using one and ...
Hi,
I'm looking for an open source project that provides a file manager type interface to S3. The ability to view files and "folders", add/edit/delete files/folders, etc.
I've seen http://s3fm.com, but I'd like to host something like that myself. Does anything like this exist?
Thanks.
...
Consider:
class Person < ActiveRecord::Base
class << self
def setup
has_one :address, :as => :addressable
end
end
end
class Employee < Person
setup
end
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
# Shouldn't this be 'Employee'? Is it possible to override?
Employee.create....
Consider the equation below:
2 ** n = A
Let us assume A=64.
What is the easiest way to find the value of n?
I am currently using following two approaches
A= 64; n = 1; n+=1 while (A >> n) > 0; n-1
A= 64; n = 0; n+=1 until (A == ( 2 ** n));n
Is there a better approach?
Other way of stating the same problem:
2 = nth root A
If I k...
I am a newbie to Ruby on Rails and I am trying to learn it.
At the moment, I am using ruby tutorial that is about 5 years old.
I am stuck on the 2nd page of the tutorial where I am generating a script or the controller in the command window.
C:\rails> ruby script\generate controller MyTest
ruby: No such file or directory script/gene...
I have a few select elements in my views that are supposed to fire after the user chooses an item from the dropdown.
My selects look like this:
<%= collection_select(:project, :id, projects, 'id', 'name', { },{:style => "width:150px", :onchange => "document.getElementById('project_btn').click()" }) %>
<span class="control_button_li...
So I have an app where I am tracking a number of things, including flowers. Depending on the type of flower they can be available from places during certain spans of time during the year. Sometimes they can even be available during multiple spans of time (eg domestically from Mar-Jun, but can be found internationally from Sept-Dec).
W...
I've got a simple app deployed to a Mac mini running 10.5.8
How would I go about restarting the Delayed Job worker anytime the computer is restarted?
...